# General solutions for the Diophantine equation $ax+by+cxy=d$

I'm trying to find a formula for the general solutions for the equation $ax+by+cxy=d$.

I know the general solutions for the Diophantine equation $ax+by=c$ are as follows: Denote $d=gcd(a,b)$;

1. A solution exists iff $d|c$
2. $(x_0,y_0)$ is a solution iff the solutions are exactly $(x,y) = (x_0+nb/d,y_0-na/d)$ s.t $n$ is an integer

For the equation $ax+by+cxy=d$ i have only the first part: i know the equation is equivalent to the equation $(cx+a)(cy+b)=ab+cd$ hence there is a solution iff it is possible to factor $ab+cd$ to 2 factors congruent to $a$ and $b$ modulo $c$.

I know i can factor the right side of the equation to 2 factors in every possible way and check one by one and get all solutions. Is it possible that there is a better way to find the solutions?

Thanks for any help!

• The old question here offers some help, too, I think. So it is useful to have the link. Oct 9, 2017 at 12:20
• Oh, i somehow missed this question, i was talking about a different one. I will edit the question soon. Thanks. Oct 9, 2017 at 12:35

$$ax+by+cxy=d$$ $$cxy + ax+by=d$$ $$c^2xy + acx+bcy=cd$$ $$c^2xy + acx+bcy + ab= ab +cd$$ $$(cx+b)(cy+a)= ab +cd$$ To finish, find all integer products $$mn = ab+cd,$$ both positive and negative $m,n,$ then take all $$cx+b = m; \; \; cy+a = n$$ for which both $x,y$ are integers, maybe positive, maybe negative.
You can write $$y(cx+b)= -ax+d \Longrightarrow cx+b|-ax+d$$ Now $$cx+d\; |\; \big[a(cx+b)+c(-ax+d)\big] = ab-cd$$ Let $m= ab-cd$ and so $$x\in \Big{\{}{k-d\over c}\in\mathbb{Z}, \;k\,|\,m \Big{\}}$$