Computing determinant of a matrix with non-zero values on three diagonals let $A$ be an $n\times n$ matrix with entries $a_{ij}$ such that
$a_{ij}=2$ if $i=j$.
$a_{ij}=1$ if $|i-j|=2$
and $a_{ij}=0$ otherwise.
compute the determinant of $A$.
using the famous formula $\det A=\sum_{i=1}^{n}(-1)^{i+j}a_{ij}\det A^{(ij)}$ where $A{(ij)}$ is the submatrix obtaining from $A$ by omiting it's $i$th row and $j$th colomn, I reached to the formula $\det A=\frac{1}{4}n^2+n+\frac{7}{8}+\frac{1}{8}(-1)^n$. is it correct?
 A: In Mathematica, the code
f[n_] := Table[
  Which[i == j, 2, Abs[i - j] == 2, 1, True, 0],
  {i, 1, n}, {j, 1, n}
  ];
Table[Det@f@n, {n, 1, 20}]

results in 
{2, 4, 6, 9, 12, 16, 20, 25, 30, 36, 42, 49, 56, 64, 72, 81, 90, 100, 110, 121}

Searching for that sequence in the OEIS results in this and your formula is (up to replacing $n$ by $n+2$) the first one given there.
I'd say that the answer is therefore Yes :D
N.B. You should contact the OEIS so that they add this interpretation ofthe sequence of the (pretty impressive!) list they already have. 
A: Cinkir develops in his paper a formula for the determinant of a pentadiagonal Toeplitz matrix. Specializing to your case, let
$$\mathbf P=\begin{pmatrix}a&b&c&&\\b&a&b&c&\\c&b&a&\ddots&\ddots\\&c&\ddots&\ddots&\\&&\ddots&&\end{pmatrix}$$
and consider the associated polynomial $p(x)=cx^4+bx^3+ax^2+bx+c$. The paper gives an expression for the determinant of $\mathbf P$ in terms of the roots of $p(x)$, with limiting cases considered if $p(x)$ has repeated roots.
For your specific case, $p(x)=(x^2+1)^2$; the formula for $\det \mathbf P$ if $p(x)$ takes the form $(x-r)^2(x-s)^2$ goes like
$$\det \mathbf P=\frac{r^{2 n+4}-r^{n+1} s^{n+1} \left((n+2)^2 r^2-2 (n+1) (n+3) r s+(n+2)^2 s^2\right)+s^{2 n+4}}{(r-s)^4}$$
Letting $r=i$ and $s=-i$ yields your formula.
A: If $A$ is of this form
$$A_{7\times 7}=
\begin{pmatrix}
     2   &  0   &  1  &   0  &   0  &   0  &   0 \\
     0   &  2   &  0  &   1  &   0  &   0  &   0 \\ 
     1   &  0   &  2  &   0  &   1  &   0  &   0 \\ 
     0   &  1   &  0  &   2  &   0  &   1  &   0 \\ 
     0   &  0   &  1  &   0  &   2  &   0  &   1 \\ 
     0   &  0   &  0  &   1  &   0  &   2  &   0 \\ 
     0   &  0   &  0  &   0  &   1  &   0  &   2 \\ 
\end{pmatrix},
$$
I get 
$$
\det(A) = 
\begin{cases}
\frac{n^2}{4}+n+1,\quad n \text{  even}\\
\quad\\
\frac{n^2}{4}+n+\frac{3}{4},\quad n  \text{  odd}
\end{cases}
$$
This is just an alternative way of stating the questioner's own succint answer:
$$\det(A) = \frac{n^2}{4}+n+\frac{7}{8} +(-1)^n\frac{1}{8}.$$
This is a nice exercise in symbolic $LU=A$ factorization and would be a good exam question to separate the good from the mediocre students. 
