I have been struggling with finding an analytic form for the following expression: $$ a_n=\sum\limits_{k=0}^n\binom{n}{k}p^k(1-p)^{n-k}A_{n,k}\left[(1+A_{n,k})(1-q+(1-p)A_{n,k})(q+pA_{n,k})\right]^{-1} $$ where $A_{n,k}=(\frac{p}{q})^k(\frac{1-p}{1-q})^{n-k}$ and $0<q<p<1$.
EDIT 2: I am editing the question to being interested in $\sum\limits_{n=0}^m a_n$ so that I may accept @mathlove 's second answer, which is the one which (imo) makes the most progress in the desired direction (end of EDIT 2)
In fact, I am also interested in $\sum\limits_{m=1}^M\frac12-(p-q)^2\sum\limits_{n=0}^m a_n$ (because the limit $\lim\limits_{m\to\infty}(p-q)^2\sum\limits_{n=0}^m a_n=\frac12$, which I "know" numerically), with $M$ being some number or potentially going to $\infty$ (because, from what I can tell numerically, this series converges, see this Wolfram notebook). I say this in case solving for one of these sums is actually simpler, but I believe that I will be able to figure this out if I can make some headway on $a_n$ itself.
So far, I have stumbled on this website onto a few references to the book A=B, and the term of "creative telescoping". Unfortunately, after scanning the book, I am led to believe that the algorithms for such telescoping do not work in this case since the function is not (unless I am mistaken) hypergeometric. However, I am hopeful that some other type of creative telescoping would work here, just there is, as far as I can tell, no universal way of achieving this here and so far I have not found any way to do so.
The main issue seems to reside in the portion that is on the denominator (the term in brackets to the $-1$ power), which has $1+x$ terms inside which are causing me a headache because it prevents the usual technique of simplifying the powers when searching for a recurrence by expressing it as a ratio of two successive terms. If we call that term in brackets $F_{n,k}$, I think it could be interesting to find a recurrence over it, but so far I have failed to find one. I have tried expressing it as a function of $F_{n-1,k-1}$ and $F_{n,k-1}$ but no success this way so far. I also tried writing the ratio $F_{n,k}/F_{n-1,k-1}$, by using logs, but so far this is a dead end.
Any suggestions on paths forward would be appreciated!
PS: although I am dealing in discrete sums, if any continuous results do exists I am also interested as I can perhaps make some connections that way.
== Edit 1 ==
@mathlove, in their derivations here and in a related post, introduce $D_{n,k}=\left(\dfrac{1}{p}\right)^k\left(\dfrac{1}{1-p}\right)^{n-k}+\left(\dfrac{1}{q}\right)^k\left(\dfrac{1}{1-q}\right)^{n-k}$. By working on solving $a_n$, I get to (I hope this is correct but it seems to check out): $$ a_n=\sum\limits_{k=0}^n\binom{n}{k}\frac{1}{D_{n,k}}-\sum\limits_{k=0}^{n+1}\binom{n+1}{k}\frac{1}{D_{n+1,k}} $$ It is tempting to think that this would telescope, but the fact that $D_{n,k}$ is on the denominator has me struggling...
You have a nice idea in Edit 1.
This answer proves the following claims :
Claim 1 : $\ \ a_n=\dfrac{1}{(q-p)^2}(G_n-G_{n+1})$ where $G_n=\displaystyle\sum_{k=0}^{n}\binom nk\dfrac{1}{D_{n,k}}$
Claim 2 : $\ \ \displaystyle\sum_{n=0}^{m}a_n=\frac{1}{(q-p)^2}\bigg(\frac 12-G_{m+1}\bigg)$
Claim 3 : $\ \ \displaystyle\lim_{m\to\infty}(p-q)^2\sum_{n=0}^{m}a_n=\dfrac 12$
Claim 4 : $\ \ \displaystyle\frac{(q+1-p)^2}{2(p-q)}\lt\lim_{M\to\infty}\sum_{m=1}^{M}\bigg(\frac 12-(p-q)^2\sum_{n=0}^{m}a_n\bigg)\leqslant \frac{(\sqrt{pq}+\sqrt{(1-p)(1-q)})^2}{2(1-\sqrt{pq}-\sqrt{(1-p)(1-q)})}$
Claim 1 : $\ \ a_n=\dfrac{1}{(q-p)^2}(G_n-G_{n+1})$ where $G_n=\displaystyle\sum_{k=0}^{n}\binom nk\dfrac{1}{D_{n,k}}$
Proof :
We have $$\begin{align}a_n&=\frac{1-p}{(q-p)^2}e_n-\frac{b_n}{(q-p)^2} \\\\&=\frac{1-p}{(q-p)^2}\bigg(\frac{1}{1-p}-\frac{1}{1-p}\sum_{k=0}^{n+1}\binom{n+1}{k}\frac{1}{D_{n+1,k}}\bigg) \\&\qquad\quad -\frac{1}{(q-p)^2}\bigg(1-\sum_{k=0}^{n}\binom nk\frac{1}{D_{n,k}}\bigg) \\\\&=\frac{1}{(q-p)^2}(G_n-G_{n+1})\end{align}$$
where $b_n=\displaystyle\sum_{k=0}^{n}\binom nkp^k(1-p)^{n-k}\frac{A_{n,k}}{A_{n,k}+1}$.
Claim 2 : $\ \ \displaystyle\sum_{n=0}^{m}a_n=\frac{1}{(q-p)^2}\bigg(\frac 12-G_{m+1}\bigg)$
Proof :
$$\begin{align}\sum_{n=0}^{m}a_n&=\frac{1}{(q-p)^2}\sum_{n=0}^{m}(G_n-G_{n+1}) \\\\&=\frac{1}{(q-p)^2}(G_0-G_{m+1}) \\\\&=\frac{1}{(q-p)^2}\bigg(\frac 12-G_{m+1}\bigg)\end{align}$$
Claim 3 : $\ \ \displaystyle\lim_{m\to\infty}(p-q)^2\sum_{n=0}^{m}a_n=\dfrac 12$
Proof :
This answer shows that $\displaystyle\lim_{m\to\infty}G_{m+1}=\lim_{m\to\infty}(1-b_{m+1})=0$.
Therefore, we have $$\lim_{m\to\infty}(p-q)^2\sum_{n=0}^{m}a_n=\lim_{m\to\infty}\bigg(\frac 12-G_{m+1}\bigg)=\frac 12$$
Claim 4 : $\ \ \displaystyle\frac{(q+1-p)^2}{2(p-q)}\lt\lim_{M\to\infty}\sum_{m=1}^{M}\bigg(\frac 12-(p-q)^2\sum_{n=0}^{m}a_n\bigg)\leqslant \frac{(\sqrt{pq}+\sqrt{(1-p)(1-q)})^2}{2(1-\sqrt{pq}-\sqrt{(1-p)(1-q)})}$
Proof :
We have $$\begin{align}\sum_{m=1}^{M}\bigg(\frac 12-(q-p)^2\sum_{n=0}^{m}a_n\bigg)&=\sum_{m=1}^{M}G_{m+1}\end{align}$$ Then, we have $$\sum_{m=1}^{M}G_{m+1}\gt\sum_{m=1}^{M}\frac 12C^{m+1}=\frac{C^2-C^{M+2}}{2(1-C)}$$ and $$\sum_{m=1}^{M}G_{m+1}\leqslant\sum_{m=1}^{M}\frac 12B^{m+1}=\frac{B^2-B^{M+2}}{2(1-B)}$$ where $B=\sqrt{pq}+\sqrt{(1-p)(1-q)}$ and $C=q+1-p$.
The claims follows from these.