How to calculate this determinant of a $2\times 2$matrix? This matrix arises from a homework problem which our professor gave.
We need to find the determinant of this matrix.
Does there exist any simple way to find the determinant of this matrix?

$\begin{pmatrix}
  x-pq-p+3-(q-1)(\frac{x+2-n}{x-n+2-l}) && (1-p)(2+\frac{l}{x-n+2-l})\\
  (1-q)(2+\frac{l}{x-n+2-l}) && x-pq-q+3-(p-1)(\frac{x+2-n}{x-n+2-l})
  \end{pmatrix}$

Here $n=pq$ and $l=\phi(n)+1$.
Is there any software which can calculate this large determinant?
One of my friends got $x-n+2-l$ as a factor of this determinant.
Is there any simple way to calculate this determinant?
I am stuck.
My try:
$R_1\to R_1-R_2$ gives
$\begin{pmatrix}
  x-pq-p+q+2 && -x+pq+q-p-2\\
  (1-q)(2+\frac{l}{x-n+2-l}) && x-pq-q+3-(p-1)(\frac{x+2-n}{x-n+2-l})
  \end{pmatrix}$
 A: In case you want to see my computation, I obtain the following determinant
by a direct computation and a further factorisation:
$$
\det(A)=\frac{f(p,q,x)}{((2q - 1)p - (q + x))^2},
$$
where
$$
f(p,q,x)=(2p^2q^2 + 2p^2q + 2pq^2 - 3pqx - 14pq - px + 2p - qx + 2q + x^2 + 6x + 4)(2pq - p - q - x)(pq - x - 2)
$$
Here I have substituted $n=pq$ and $l=\phi(n)+1=(p-1)(q-1)+1$.
A: Call your matrix $M$ and let $s=x+2-n$. Then
\begin{aligned}
M&=\pmatrix{
x-pq-p+3-(q-1)(\frac{x+2-n}{x-n+2-l}) &(1-p)(2+\frac{l}{x-n+2-l})\\
(1-q)(2+\frac{l}{x-n+2-l}) &x-pq-q+3-(p-1)(\frac{x+2-n}{x-n+2-l})}\\
&=\pmatrix{x-pq-p+3 &1-p\\ 1-q &x-pq-q+3}
+\frac{x+2-n}{x+2-n-l}\pmatrix{1-q&1-p\\ 1-q&1-p}\\
&=sI+\pmatrix{1-p&1-p\\ 1-q&1-q}
+\frac{s}{s-l}\pmatrix{1-q&1-p\\ 1-q&1-p}.
\end{aligned}
(The second equality above is borrowed from J.G.'s answer.)
If $l=2s$, then $\dfrac{s}{s-l}=-1$. Hence
$$
M=\pmatrix{s+q-p&0\\ 0&s+p-q}
$$
and
$$
\det(M)=s^2-(p-q)^2.
$$
If $l\ne2s$, let $t=\dfrac{s-l}{2s-l},\ p'=\dfrac{1-p}{t}$ and $q'=\dfrac{1-q}{t}$. Then
$$
M=\pmatrix{s+tp'+(1-t)q'&p'\\ q'&s+tq'+(1-t)p'}
$$
and hence
$$
\det(M)=\left(s+tp'+(1-t)q'\right)\left(s+tq'+(1-t)p'\right)-p'q'.
$$
A: It helps to rewrite your matrix as $A+B$ with$$A:=\left(\begin{array}{cc}
x-pq-p+3 & 1-p\\
1-q & x-pq-q+3
\end{array}\right),\,B:=\frac{x+2-n}{x+2-n-l}\left(\begin{array}{cc}
1-q & 1-p\\
1-q & 1-p
\end{array}\right).$$Write $A=\left(\begin{array}{cc}
a & c\\
b & d
\end{array}\right),\,B=\left(\begin{array}{cc}
e & g\\
f & h
\end{array}\right)$ so$$\begin{align}\det\left(A+B\right)&=\det A+\det B+\det\left(\begin{array}{cc}
a & g\\
b & h
\end{array}\right)+\det\left(\begin{array}{cc}
e & c\\
f & d
\end{array}\right)\\&=\left(x-pq+3\right)^{2}-\left(p+q\right)\left(x-pq+3\right)-1+p+q\\&+\frac{x+2-n}{x+2-n-l}\left[\det\left(\begin{array}{cc}
x-pq-p+3 & 1-p\\
1-q & 1-p
\end{array}\right)+\det\left(\begin{array}{cc}
1-q & 1-p\\
1-q & x-pq-q+3
\end{array}\right)\right]\\&=\left(x-pq+3\right)^{2}-\left(p+q\right)\left(x-pq+3\right)-1+p+q\\&+\frac{x+2-n}{x+2-n-l}\left[\left(x-\left(p-1\right)\left(q+1\right)+1\right)\left(1-p\right)+\left(x-\left(p+1\right)\left(q-1\right)+1\right)\left(1-q\right)\right]\\&=\left(x-pq+3\right)^{2}-\left(p+q\right)\left(x-pq+3\right)-1+p+q\\&+\frac{x+2-n}{x+2-n-l}\left[\left(1+x\right)\left(2-p-q\right)+\left(p-1\right)^{2}\left(q+1\right)+\left(p+1\right)\left(q-1\right)^{2}\right].\end{align}$$
