How many $2\times2$ positive integer matrices are there with a constant trace and positive determinant? The trace of a $2\times2$ positive integer matrix is a given constant positive value. How many possible choices are there such that the determinant is greater than 0? Each element of matrix is positive.

Suppose we're looking for a positive integer matrix with trace $M$.  The matrix must have the form
$$
\pmatrix{
M - n & a\\
b & n
}
$$
Where $a,b \geq 1$ and $1 \leq n \leq M-1$.  For the determinant to be positive, we must have
$$
(M-n)n \geq ab
$$
So, we may compute the number of matrices with trace $M$ and a positive determinant as follows:  For a given $n$ from $1$ to $M-1$, let $\phi_n(M)$ be the number of products $ab$ such that $ab \leq (M-n)n$ (order matters).  Then the total number of matrices for a given $M$ is
$$
\sum_{n=1}^{M-1}\phi_n(M)
$$
I do not know of any well known function to simplify $\phi$, but at least it is now a number theory problem.
