# Approximating higher dimension step function

Let $s \in R^{n}$ (meaning $s$ is $n \times 1$ vector), where $n$ is the dimension of the vector. The ideal sliding term, $\nu$ is taken to be: $$\nu = \frac{s}{\|s\|}$$ where $\| . \|$ is taken to be the Euclidean norm. When $n = 1$, the above equation represents a step function but with the value of at $s=0$ undefined.

So, my question is what other continuous approximations can I use to approximate the above equation such that all values are well-defined and the function is smooth? Notice that the approximation has to be able to hold true for vectors. Considering just the scalar case is not good enough for me. Ideally, I would the approximation to have the following characteristics:

1. differentiable with respect to all s
2. having a closed form expression
3. Isn't a piecewise function

I know this might sound a lot. I looking something like that so that I can use it to do Lyapunov analysis (stability theory). I have a feeling that there is something simple out there.

I have written a long description in PDF format. You can download it here. Any input is greatly appreciated. If there is anything unclear, feel free to ask me. Thank you!

-
What about $\frac{s}{(\|s\|^2+\delta)^{1/2}}$? Maybe you should state more precisely what are your requirements for the approximation –  Piero D'Ancona May 24 '13 at 7:57
I think this will still run into the problem of differentiability at 0. Because when you differentiate the expression with respect to s, you will need to use chain rule and you will have to face the problem of differentiating $\|s\|$ which is not differentiable at 0. Please correct me if I am wrong. –  Yao Hong May 24 '13 at 17:41

A first pass to get continuity: for $||s||\geq \epsilon$, $f(s) = s/||s||$. For $||s||<\epsilon$,

$f(s) = \frac{s}{||s||} (e^{1/\epsilon^2-1/||s||^2})$

If you want differentiability you just need to fiddle with the $< \epsilon$ function to have a derivative of 0 in the increasing $||s||$ direction at $||s||=\epsilon$ (I'm not quite motivated enough to figure it out)

Alternatively if you're willing to accept your function never quite being correct

$f(s) = e^{-\epsilon/||s||^2} \frac{s}{||s||}$

-
I will try to explore more on your function. But it will be nice if it wasn't piecewise. –  Yao Hong May 24 '13 at 20:32
The second option is defined for all s in one shot, not piecewise. –  David Benson-Putnins May 24 '13 at 21:58
Cool. That might just what I looking for. But why are you saying it is never quite correct? Can explain more? –  Yao Hong May 24 '13 at 22:10
Oh, but isn't the value at 0 still undefined? –  Yao Hong May 24 '13 at 22:20
wolframalpha.com/input/… It's differentiable at zero because $e^{-\epsilon/||s||^2}$ goes to zero so fast. By "never quite being correct" I meant there is no choice of s for which f(s) = s/||s|| exactly –  David Benson-Putnins May 24 '13 at 22:28
show 1 more comment

Maybe something like $$v_{\text{smoother}} := \begin{cases} \dfrac{s}{\|s\| + e^{-\frac{1}{\|s\| - c}}} & \|s\| > c \\\\ 0 & \|s\| \le c \end{cases}$$

If this specific example doesn't work, you can use tricks like this to make smooth multivariate functions.

-
But then this would be piecewise continuous. Furthermore, is it differentiable at $\|s\| = c$? Anyhow, this is an interesting answer. Can you tell me what lead you to such an answer? –  Yao Hong May 23 '13 at 14:42
@yao I was trying to abuse en.wikipedia.org/wiki/Non-analytic_smooth_function to make a smooth function, but I am too dumb to figure out whether this multivariate version is actually smooth at ||s|| = c. Maybe it's not. –  meij May 23 '13 at 16:32
You shouldn't say things as "I am too dumb to figure ...". Even I might didn't know such a thing existed. Perhaps it could somehow help along the way. I am trying to look for something that is differentiable with respect to s, which I didn't emphasized enough. –  Yao Hong May 23 '13 at 18:57
If you do not need an explicit form you could start with $$f_\epsilon(s) = \begin{cases} \frac{s}{\|s\|}, & \|s\|\geq \epsilon\\ 0, & \|s\|<\epsilon \end{cases}$$ and then use a narrow mollifier $\phi_\delta$ to form $$f_{\epsilon,\delta} = f_\epsilon\ast \phi_\delta.$$
Here is an image of the $x$ and $y$ coordinate and $f_{\epsilon,\delta}$ in two dimensions: