Is it possible to write the following matrix as a single function, without any explicit if condition mathematically?
For, $$1 \leq i,j\leq n,$$ $$A(i,j)=\begin{cases} 2 ~~\text{if}~~ i \neq j \\ 1 ~~\text{if}~~i=j \end{cases} $$
Mathematically it should be written as $$A(i,j) = f(i,j)$$
It can be combination of minimum, maximum, floor, ceil, trigonometric functions.
Without trigonometric functions: $$ A(i,j)=1+\frac{|i-j|}{\max(1,|i-j|)}. $$ Since the absolute value is not among the allowed functions, you can replace $|i-j|$ by $$ |i-j|=\max(i-j,j-i), $$ so $$ A(i,j)=1+\frac{\max(i-j,j-i)}{\max(1,i-j,j-i)}. $$