How to check if point $x \in \mathbb{R}^n$ is in a $n$-simplex? Is there any universal solution how to check if a point $x \in \mathbb{R}^n$ is in $n$-simplex for any number of dimensions (any $n$)? 
Is it possible to use Barycentric coordinates for any $n$? I have only found examples for 2 and 3 dimensions.
 A: Let be $v_0,v_1,\ldots, v_n\in \mathbb R^n$ the vertices of an n-simplex. If this simplex is non degenerated, the vectors $v^*_1=v_1-v_0,\,v^*_2=v_2-v_0,\ldots, \,v^*_n=v_n-v_0$ are linear independent so they are a basis of $\mathbb R^n$. It means
$$x-v_0=\alpha_1v^*_1+\alpha_2v^*_2+\ldots+\alpha_nv^*_n$$ where the coefficients $\alpha_1,\ldots,\alpha_n$ are uniquely determined by the point $x$. We claim $x$ is in our simplex if and only if $\alpha_i\geq 0$ for every $i=1,\ldots,n$ and $\sum\alpha_i\leq1$. To show it we compute the baricentric coordinates of $x$:
$$x=\left(\alpha_1+\ldots+\alpha_n + \left(1-\sum\alpha_i\right)\right)x=\alpha_1v_1+\ldots+\alpha_nv_n+\left(1-\sum\alpha_i\right)v_0.$$
As we know x is in the convex hull of the $v_i$s if and only if all of these coordinates aren't negative. This is equivalent to our condition qoud erat demonstrandum.
A: Yes, barycentric coordinates can be easily used with any number of dimensions to determine if a point $\textbf{p} \in \mathbb{R}^n$ is in a simplex $\textbf{S} = (\textbf{v}_1, \dots, \textbf{v}_{n+1})$, where $\textbf{v}_i \in \mathbb{R}^n, i=1,\dots,n+1$ are simplex vertexes.
Simply solve this equation, to get barycentric coordinates:
$$\lambda = \textbf{T}^{-1}(\textbf{p} - \textbf{v}_{n+1}), \;\textrm{where}\\
\textbf{T} = (\textbf{v}_1 - \textbf{v}_{n+1}, \dots, \textbf{v}_n - \textbf{v}_{n+1})^T$$
If barycentric coordinates $$\lambda = (\lambda_1, \dots, \lambda_n), \\\lambda_{n+1} = 1-\sum \lambda_i, i=1,\dots,n$$ satisfies these two conditions:
$$
\lambda_i \ge 0,\\
 \sum \lambda_i \le 1, 
\\i = 1, \dots, n+1$$
the point is in the simplex, $\textbf{p} \in \textbf{S}$.
Otherwise, its outside of the simplex, $\textbf{p} \notin \textbf{S}$.
A: Yes, it is possible for any dimension. 
The easy way to do this is using the following formula
$$
\vec{\Lambda}(x_1; x_2; \dots; x_n) =
(-1)
\frac{
    \det
    \begin{pmatrix}
        0 & \vec{e}_{1} & \vec{e}_{2} & \dots & \vec{e}_{n+1} \\
        \begin{matrix}
            x_{1} \vphantom{x_{1}^{(1)}} \\
            x_{2} \vphantom{x_{1}^{(1)}} \\
            \cdots                       \\
            x_{n} \vphantom{x_{1}^{(1)}} \\
        \end{matrix} &
%
        \begin{matrix}
            x_{1}^{(1)}  \\
            x_{2}^{(1)}  \\
            \cdots       \\
            x_{n}^{(1)}  \\
        \end{matrix} &
%
        \begin{matrix}
            x_{1}^{(2)}  \\
            x_{2}^{(2)}  \\
            \cdots       \\
            x_{n}^{(2)}  \\
        \end{matrix} &
%
        \cdots &
%
        \begin{matrix}
            \!x_{1}^{(n+1)}\! \\
            \!x_{2}^{(n+1)}\! \\
            \cdots        \\
            \!x_{n}^{(n+1)}\! \\
        \end{matrix} \\
%
        1 & 1 & 1 & \cdots & 1
    \end{pmatrix}
}{
    \det
    \begin{pmatrix}
        \begin{matrix}
            x_{1}^{(1)} \\
            x_{2}^{(1)} \\
            \cdots      \\
            x_{n}^{(1)} \\
        \end{matrix} &
%
        \begin{matrix}
            x_{1}^{(2)} \\
            x_{2}^{(2)} \\
            \cdots      \\
            x_{n}^{(2)} \\
        \end{matrix} &
%
        \cdots &
%
        \begin{matrix}
            \! x_{1}^{(n+1)}\! \\
            \!x_{2}^{(n+1)}\! \\
            \!\cdots \!       \\
           \! x_{n}^{(n+1)} \!\\
        \end{matrix} \\
%
        1 & 1 & \cdots & 1
    \end{pmatrix}
}.
$$
Here $\vec{x}^{\,(1)}$, $\dots$, $\vec{x}^{\,(n+1)}$ are vertices of the simplex,
$x_{1}$, $\dots$, $x_{n}$ --- coordinates of the point, which position you are checking, and $\vec{e}_{1}$, $\dots$, $\vec{e}_{n+1}$ are some formal orthonormal vectors.
As a result you get a "vector" $\vec{\Lambda}$, which components are barycentric coordinates of the point $\vec{x}$.
Now the easy part: check that each component $0 < \Lambda_i < 1$ and you may state that the point $\vec{x}$ is inside the simplex, otherwise it is not.
Situation when some $\Lambda_{i}$-s are equal zero means that the point is "on the edge", but this case needs more consideration.
To read more on the theory behind the scene, you may want to check "Beginner's guide to mapping simplexes affinely" that is written by authors of the formula, or check concrete example in their "Workbook on mapping simplexes affinely".
