# Finding $\frac{\cos(b)}{\cos(a)}$ given $\cos(x) e^{i y} = \frac{\sin(a)}{\sin(a+b)}$ and $-i \sin(x) e^{i y} = \frac{\sin(b)}{\sin(a+b)}$

I have real $$x$$ and $$y$$, and I have the following implicit definitions of (complex) $$a$$ and $$b$$:

$$\cos(x) e^{i y} = \frac{\sin(a)}{\sin(a+b)}$$ $$-i \sin(x) e^{i y} = \frac{\sin(b)}{\sin(a+b)}$$

I want to re-express $$\frac{\sin(b)}{\sin(a)}$$ and $$\frac{\cos(b)}{\cos(a)}$$ in terms of just $$x$$ and $$y$$. The former is easy -- dividing the two implicit definitions gives

$$\frac{\sin(b)}{\sin(a)} = -i \tan(x)$$

while I'm currently stuck on finding $$\frac{\cos(b)}{\cos(a)}$$.

Is there a way in Mathematica to re-express $$\frac{\sin(b)}{\sin(a)}$$ and $$\frac{\cos(b)}{\cos(a)}$$ in terms of just $$x$$ and $$y$$?

In this particular case, it's difficult to solve the implicit definitions of $$a,b$$ explicitly in terms of $$x,y$$, but the simplicity of $$\frac{\sin(b)}{\sin(a)}$$ gives me hope that it can be done in Mathematica. I will accept any method that works for the above problem, but I would appreciate a comment on more generally re-expressing functions in terms of new coordinates when the coordinate change is only given implicitly.

For easier copy-paste, I've gathered some of the expressions below:

Cos[x] Exp[I y] = Sin[a]/Sin[a + b]

-I Sin[x] Exp[I y] = Sin[b]/Sin[a + b]

Sin[b]/Sin[a]

Cos[b]/Cos[a]

• It would be useful to have these various inputs in Mathematica copy-pastable format. Commented Mar 31 at 3:10
• @DanielLichtblau Good idea, I've added in the key expressions in Mathematica copy-pastable format. Commented Mar 31 at 3:28
• @user196574 the way is clear - expand the Sin[a+b], take the Cos[b]/Cos[a] from Sin[a+b]/Sin[a] and Sin[a+b]/Sin[b] and so on with replacement of the Sin[b]/Sin[a] from your first solution.. The answer looks like a Cos[b]/Cos[a]=0, If I did not put mistakes.. Commented Mar 31 at 6:04

Expand differences as exponentials and set numerators to zeros

cc = {(Cos[x] Exp[I y] - Sin[a]/Sin[a + b] // TrigToExp // Together //
Numerator) == 0,
(-I Sin[x] Exp[I y] - Sin[b]/Sin[a + b] // TrigToExp // Together //
Numerator) == 0}


$$e^{2 i a+2 i b+2 i x+i y}-2 e^{2 i a+i b+i x}+e^{2 i a+2 i b+i y}+2 e^{i b+i x}-e^{2 i x+i y}-e^{i y}=0$$ $$-e^{2 i a+2 i b+2 i x+i y}-2 e^{i a+2 i b+i x}+e^{2 i a+2 i b+i y}+2 e^{i a+i x}+e^{2 i x+i y}-e^{i y}=0$$

Expand integer multiples of exponents to powers of exponentials

       ccp = cc //.
{E^(a_ + b__) :> q[a] E^Plus[b], E^a_ :> q[a],
q[2 I a_] :> q[I a]^2}


$$q(i a)^2 q(i b)^2 q(i x)^2 q(i y)-2 q(i a)^2 q(i b) q(i x)+q(i a)^2 q(i b)^2 q(i y)+2 q(i b) q(i x)-q(i x)^2 q(i y)-q(i y)=0$$ $$-q(i a)^2 q(i b)^2 q(i x)^2 q(i y)-2 q(i a) q(i b)^2 q(i x)+q(i a)^2 q(i b)^2 q(i y)+2 q(i a) q(i x)+q(i x)^2 q(i y)-q(i y)=0$$

Solve for desired q's and restore exponentials

  Solve[ccp, {q[I a], q[I b]}][[-1]] /. {q[x_] :> E^x} // FullSimplify


$$e^{i a}\to \frac{e^{-i y} \left(i \sin (x+2 y)+\cos (x+2 y)+\sqrt{2} \sqrt{e^{2 i (x+y)} (\cos (2 y)-\cos (2 x))}-i \sin (x)-\cos (x)\right)}{-1+e^{2 i x}}$$ $$e^{i b}\to \frac{e^{-i y} \left(e^{i x} \left(1+e^{2 i y}\right)-\sqrt{2} \sqrt{e^{2 i (x+y)} (\cos (2 y)-\cos (2 x))}\right)}{1+e^{2 i x}}$$

that can be reduced (by hand, hopefully correct) to

$$e^{i a}\to \frac{e^{2 i y}+\sqrt{-e^{2 i x+2 i y}-e^{-2 \text{ix}+2 i y}+e^{4 i y}+1}-1}{e^{i x+i y}-e^{-\text{ix}+i y}}$$ $$e^{i b}\to \frac{e^{2 i y}-\sqrt{-e^{2 i x+2 i y}-e^{-2 \text{ix}+2 i y}+e^{4 i y}+1}+1}{e^{i x+i y}-e^{-\text{ix}+i y}}$$

• This gives the nice compact result that $\frac{\cos(b)}{\cos(a)} = \cot(y) \tan(x)$. Thanks for the systematic run-through. I learned a lot of good techniques in Mathematica! The $e^a \to q(a)$ trick seems like a good technique for solving transcendental equations. Do you have a sense of whether this could be automated, like whether one could say "re-express $f(a,b)$ in terms of $x,y$ given these implicit relations for $a,b$ in terms of $x,y$?" I think maybe I'll ask that as a separate question. If you do Simplify instead of FullSimplify, you can do a little less work by hand. Commented Mar 31 at 17:02
• Or maybe I should rephrase it -- do you have a sense of how to solve the problem in Mathematica if it weren't possible to explicitly solve $a,b$ in terms of $x,y$? Commented Mar 31 at 17:02
• In the first place its a techique comparable to Fourier expansion (TrigReduce) for harmonic forms that I used to switch off Mathematica's standard simplifcation technics for exponentials and trigs. The main strength of CAS's is polynomial algebra. The use of transcendentals obcsures these simple algorithims by the fact, that nobody dares to simplify log's without unreadable compex domain definitions. Commented Mar 31 at 17:21

I'd tackle this as an algebraic elimination problem, making polynomials from the trigs. It simplifies if we first rewrite the left-hand-sides (in the x-y variables) as two different algebraic variables. We also need a "polynomial" that encodes the desired relation Cos[b]/Cos[a] as a result.

exprs = {Sin[a]/Sin[a + b] - exy1, Sin[b]/Sin[a + b] - exy2,
Cos[b] - result*Cos[a]};


Now change the trigs into inert things to avoid unwanted trig identities, and add the usual identities for these new variables.

tpolys =
Numerator@Together@TrigExpand[exprs] /. {Sin -> sin, Cos -> cos};
extra = {sin[a]^2 + cos[a]^2 - 1, sin[b]^2 + cos[b]^2 - 1};
allpolys = Join[tpolys, extra];


Use GroebnerBasis to eliminate the {a,b} parts.

gb =
GroebnerBasis[
allpolys, {result, exy1, exy2}, {cos[a], sin[a], cos[b], sin[b]}]

(* Out[343]= {-exy2 - exy1^2 exy2 + exy2^3 + exy1 result -
exy1^3 result + exy1 exy2^2 result + exy2 result^2 +
exy1^2 exy2 result^2 - exy2^3 result^2 - exy1 result^3 +
exy1^3 result^3 - exy1 exy2^2 result^3} *)


Solve for the result.

In[340]:= SolveValues[gb[[1]] == 0, result]

(* Out[340]= {-1, 1, (-exy2 - exy1^2 exy2 + exy2^3)/(
exy1 (-1 + exy1^2 - exy2^2))} *)


It's the third one we care about. Backsubstitute for those x-y variables into the result, and simplify like so.

sol = SolveValues[gb[[1]] == 0, result][[3]];
Simplify[
ExpToTrig[
sol /. {exy1 -> Cos[x]*Exp[I*y], exy2 -> -I*Sin[x]*Exp[I*y]}],
Assumptions -> Element[{x, y}, Reals]]

(* Out[346]= Cot[y] Tan[x] *)

• very nice and educational. Thank you.+1. :) Commented Apr 1 at 20:02

Assuming $$a,b,x,y$$ are real and that no division by zero you can mutliply first equation by $$\cos(b)$$ and second by $$\cos(a)$$ and add and then by manipulation yields result already found.

You can emulate step by step hand work (suppressing all the conditions: you can look at if you wish):

p1 = Cos[x] Exp[I  y] == Sin[a]/Sin[a + b]
p2 = -I  Sin[x] Exp[I  y] == Sin[b]/Sin[a + b]
p3 = MultiplySides[p1, Cos[b]][[1, 1, 1]]
p4 = MultiplySides[p2, Cos[a]][[1, 1, 1]]
p5 = AddSides[p3, p4] // Simplify
p6 = ComplexExpand[MultiplySides[p5, Exp[-I  y]][[1, 1, 1]]]
p7 = p6[[1]] /. u_ - I  v_ :> u == p6[[2]] /. u_ - I  v_ :> u
p8 = p6[[1]] /. u_ - I  v_ :> v == p6[[2]] /. u_ - I  v_ :> v
p9 = DivideSides[p7, p8][[1, 1, 1]]
MultiplySides[p9, Tan[x]][[1, 1, 1]]


The latter is: $$\frac{\cos(b)}{\cos(a)}=\cot(y)\tan(x)$$