Orlicz functions

Binder - link to interactive notebooks session.

A map \(\Phi :\mathbb{R}\rightarrow \left[ 0,\infty \right]\) is said to be an Orlicz function if it is even, convex, left continuous on the whole \(\mathbb{R}_{+},\) \(\Phi (0)=0\) and \(\Phi \) is not identically equal to zero. Since \(\Phi \) is even, without loss of generality we often consider \(\Phi \) with the domain restricted to the interval \(\left[ 0,\infty \right) .\) It follows that every Orlicz function \(\Phi \) is non-decreasing on \(\mathbb{R}% _{+}.\) In this paper, because \(\Phi\) is even, we will always define Orlicz function for \(u\geq 0.\)

We will use two types of definitions of the Orlicz functions. Both work with numpy arrays as arguments and return numpy arrays.

import numpy as np
import numerical_function_spaces.orlicz_spaces as osm

Simplest Orlicz function

def Orlicz_function(u):
    return u ** 2

Above definition works for floats and numpy arrays

print(Orlicz_function(2))
4
u = np.arange(0, 10, 0.5)
print(u)
print(Orlicz_function(u))
[0.  0.5 1.  1.5 2.  2.5 3.  3.5 4.  4.5 5.  5.5 6.  6.5 7.  7.5 8.  8.5
 9.  9.5]
[ 0.    0.25  1.    2.25  4.    6.25  9.   12.25 16.   20.25 25.   30.25
 36.   42.25 49.   56.25 64.   72.25 81.   90.25]
osm.plot_Phi(Orlicz_function, u_max=5, du=0.1)
_images/1776e4879140a5e76259d64f24f88d40e0e13ab7c9ec179db93c4a0db4a4a5c5.png
def Orlicz_function(u):
    return np.where(u <= 1, 0, u - 1)

Above definition also works for floats and numpy arrays

print(Orlicz_function(2))
1
u = np.arange(0, 10, 0.5)
print(u)
print(Orlicz_function(u))
[0.  0.5 1.  1.5 2.  2.5 3.  3.5 4.  4.5 5.  5.5 6.  6.5 7.  7.5 8.  8.5
 9.  9.5]
[0.  0.  0.  0.5 1.  1.5 2.  2.5 3.  3.5 4.  4.5 5.  5.5 6.  6.5 7.  7.5
 8.  8.5]

The same function for numpy array we may defined as

def Orlicz_function(u):
    """
    'u' should be a numpy array or function must be a little complicated
    """
    Phi = np.zeros(len(u))
    for i in range(len(u)):
        if u[i] <= 1:
            Phi[i] = 0
        else:
            Phi[i] = u[i] - 1
    return Phi

Such defined function doesn’t work for a number

try:
    Orlicz_function(2)
except Exception as error:
    print("An error occurred:", error)
An error occurred: object of type 'int' has no len()

But works for numpy array

u = np.arange(0, 10, 0.5)
print(u)
print(Orlicz_function(u))
[0.  0.5 1.  1.5 2.  2.5 3.  3.5 4.  4.5 5.  5.5 6.  6.5 7.  7.5 8.  8.5
 9.  9.5]
[0.  0.  0.  0.5 1.  1.5 2.  2.5 3.  3.5 4.  4.5 5.  5.5 6.  6.5 7.  7.5
 8.  8.5]
osm.plot_Phi(Orlicz_function, u_max=10, du=0.1)
_images/824bfb633ff732a93de70a992b87ec7290a218fda6f75bd3f1cfda1ba371a704.png

Another examples of Orlicz functions

def Orlicz_function(u):
    return np.where(u <= 1, 0, np.where(u <= 2, u - 1, u ** 2 - 3))

The same function for numpy array we may defined as

def Orlicz_function(u):
    Phi = np.zeros(len(u))
    for i in range(len(u)):
        if u[i] <= 1:
            Phi[i] = 0
        elif u[i] <= 2:
            Phi[i] = u[i] - 1
        else:
            Phi[i] = (u[i]) ** 2 - 3
    return Phi
osm.plot_Phi(Orlicz_function, u_max=5, du=0.1)
_images/97e85d6f0b72c14c4efa07f16eb0633639f85967e6b4963bbd17eb3fa54b0d29.png
def Orlicz_function(u):
    # return np.where(u <= 1, u, np.inf)
    # or 
    Phi = np.zeros(len(u))
    for i in range(len(u)):
        if u[i] <= 1:
            Phi[i] = u[i]
        else:
            Phi[i] = np.inf
    return Phi
osm.plot_Phi(Orlicz_function, u_max=5, du=0.1)
_images/672361dec7b1dfb61709dbfc1aec2a96540b5dfabc6561d52d43cc2755a3807e.png
def Orlicz_function(u):
    # return np.where(u <= 1, u / (1 - u), np.inf)
    # or 
    Phi = np.zeros(len(u))
    for i in range(len(u)):
        if u[i] < 1:
            Phi[i] = u[i] / (1 - u[i])
        else:
            Phi[i] = np.inf
    return Phi

osm.plot_Phi(Orlicz_function, u_max=5, du=0.05)
_images/8a86f5580741af5b248bfa5358ad92c0da78962e2a224e3e6b87ef7ff68bd5d1.png
def Orlicz_function(u):
    # return np.where(u <= 2, u / 2, np.where(u <= 4, (u / 2) ** (u / 2), np.inf))
    # or
    Phi = np.zeros(len(u))
    for i in range(len(u)):
        if u[i] <= 2:
            Phi[i] = u[i] / 2
        elif u[i] <= 4:
            Phi[i] = (u[i] / 2) ** (u[i] / 2)
        else:
            Phi[i] = np.inf
    return Phi

osm.plot_Phi(Orlicz_function, u_max=7, du=0.01)
_images/ed36432c0ab497516c11a02496415ee53c82b7f01a10005a08dbada4e6dd563e.png

More complicated examples

def Orlicz_function(u):
    Phi = np.zeros(len(u))
    for i in range(len(u)):
        n = -1
        while True:
            if u[i] > n and u[i] <= n + 1:  # below two conjugated functions?
                Phi[i] = (n + 1) * u[i] - (n + 1) * n / 2
                # Phi[i] = n * u[i] - (n) * (n + 1) / 2
                break
            n = n + 1
    return Phi
osm.plot_Phi(Orlicz_function, u_max=3.5, du=0.05)
_images/2a12bed482ede1a4d528eb3cf46c6b201cb9b92b0712465e1d730fdeab1c6658.png
def Orlicz_function(u):
    Phi = np.zeros(len(u))
    for i in range(len(u)):
        n = -1
        while True:
            if u[i] > n and u[i] <= n + 1:  # below two conjugated functions?
                # Phi[i] = (n + 1) * u[i] - (n + 1) * n / 2
                Phi[i] = n * u[i] - (n) * (n + 1) / 2
                break
            n = n + 1
    return Phi
osm.plot_Phi(Orlicz_function, u_max=3.5, du=0.05)
_images/dde1a6721c8aaeda3d0b747a84e8ec38fed5c475b9bce4ba12a21b2e1d6ca51d.png