# System of two nonlinear equations in two variables

I would like to solve the following system of equations, where $$x \in \mathbb{R}$$ and $$y\in \mathbb{R}$$ are unknowns and $$a,b,c,d,e \in \mathbb{R}$$ are constants

$$(x+\frac{1}{x} -a)/(\frac{x}{y}+\frac{y}{x} -e) =c\\ (y+\frac{1}{y}-b)/(\frac{x}{y}+\frac{y}{x}-e)=d$$

I cannot find any smart substitution, and sympy appears not to be able to solve it.

First, make the ratio to get $$\frac{x+\frac{1}{x}-a}{y+\frac{1}{y}-b}=\frac c d$$ This gives a quadratic in $$y$$ which has two solutions $$y_\pm$$ (even if they are complex).

Now, in one of the equations, replace $$y$$ by $$y_+$$ and then $$y_-$$. This gives a monster in $$x$$.

For$$(a,b,c,d,e)$$, let us use $$(1,2,3,4,5)$$ this gives $$y_+=\frac{4 x^2+2x+4+\sqrt{\left(4 x^2+2 x+4\right)^2-36 x^2}}{6 x}$$ and $$x$$ is solution of $$1+8x-x^2-25x^3-x^4+8x^5+x^6=0$$

Maxima:

E1 : (x + 1/x - a) - c*(x/y + y/x - e);
E2 : (y + 1/y - b) - d*(x/y + y/x - e);

E3 : expand(E1*y);
E4 : expand(E2*y);

E5: expand(E3*(1 - d/x) + E4*c/x);

E6 : solve(E5,[y]);
E7 : subst(part(E6[1],2),y,E3);
E8 : solve(E7,[x]);


$$(x+\frac{1}{x} -a)/(\frac{x}{y}+\frac{y}{x} -e) =c \tag{1}$$ $$(y+\frac{1}{y}-b)/(\frac{x}{y}+\frac{y}{x}-e)=d \tag{2}$$

From $$(1)$$ multiply out the denominator E1 : (x + 1/x - a) - c*(x/y + y/x - e); $$-c\,\left({{y}\over{x}}+{{x}\over{y}}-e\right)+x+{{1}\over{x}}-a \tag{3}$$

From $$(2)$$ multiply out the denominator E2 : (y + 1/y - b) - d*(x/y + y/x - e); $$-d\,\left({{y}\over{x}}+{{x}\over{y}}-e\right)+y+{{1}\over{y}}-b \tag{4}$$

Multiply $$(3)$$ by $$y$$ : E3 : expand(E1*y); $$-{{c\,y^2}\over{x}}+x\,y+{{y}\over{x}}+c\,e\,y-a\,y-c\,x \tag{5}$$

Multiply $$(4)$$ by $$y$$ : E4 : expand(E2*y); $$-{{d\,y^2}\over{x}}+y^2+d\,e\,y-b\,y-d\,x+1 \tag{6}$$

Cancel out $$y^2$$ between $$(5)$$ and $$(6)$$ : E5: expand(E3*(1 - d/x) + E4*c/x); $$x\,y+{{a\,d\,y}\over{x}}-{{b\,c\,y}\over{x}}+{{y}\over{x}}-{{d\,y }\over{x^2}}+c\,e\,y-d\,y-a\,y-c\,x+{{c}\over{x}} \tag{7}$$

Solve for $$y$$ : E6 : solve(E5,[y]);

$$y={{c\,x^3-c\,x}\over{x^3+\left(c\,e-d-a\right)\,x^2+\left(a \,d-b\,c+1\right)\,x-d}} \tag{8}$$

Substitute $$y$$ into $$(5)$$ : E7 : subst(part(E6[1],2),y,E3);

$$-{{c\,\left(c\,x^3-c\,x\right)^2}\over{x\,\left(x^3+\left(c\,e-d-a \right)\,x^2+\left(a\,d-b\,c+1\right)\,x-d\right)^2}}+{{x\,\left(c\, x^3-c\,x\right)}\over{x^3+\left(c\,e-d-a\right)\,x^2+\left(a\,d-b\,c +1\right)\,x-d}}+{{c\,x^3-c\,x}\over{x\,\left(x^3+\left(c\,e-d-a \right)\,x^2+\left(a\,d-b\,c+1\right)\,x-d\right)}}+{{c\,e\,\left(c \,x^3-c\,x\right)}\over{x^3+\left(c\,e-d-a\right)\,x^2+\left(a\,d-b \,c+1\right)\,x-d}}-{{a\,\left(c\,x^3-c\,x\right)}\over{x^3+\left(c \,e-d-a\right)\,x^2+\left(a\,d-b\,c+1\right)\,x-d}}-c\,x \tag{9}$$

Solve for $$x$$: E8 : solve(E7,[x]);

$$0=d\,x^6+\left(c\,d\,e-d^2-2\,a\,d-c^2+b\,c-1\right)\,x^5+ \left(a\,\left(-c\,d\,e+2\,d^2-b\,c+2\right)+b\,\left(c^2\,e-2\,c\,d \right)-2\,c\,e+a^2\,d+3\,d\right)\,x^4+\left(c^2\,\left(2-e^2 \right)+a\,\left(2\,c\,e+2\,b\,c\,d-4\,d\right)+2\,c\,d\,e-2\,d^2+a^ 2\,\left(-d^2-1\right)-b^2\,c^2+2\,b\,c-2\right)\,x^3+\left(a\, \left(-c\,d\,e+2\,d^2-b\,c+2\right)+b\,\left(c^2\,e-2\,c\,d\right)-2 \,c\,e+a^2\,d+3\,d\right)\,x^2+\left(c\,d\,e-d^2-2\,a\,d-c^2+b\,c-1 \right)\,x+d \tag{10}$$