# Why won't Mathematica display an answer? [duplicate]

I have the following piece of code that relates 4 variables: a1, a2, b1, and b2. There are 4 independent equations (including a1=1), meaning that all variables should have a unique solution. But the result is just empty for b2. And if I try to solve for a2, it just displays the first line of the matrix equation that I put in. What is going on here?

Clear["Global*"]
a1 = 1;
Solve[{a2, b2} ==
{{t, -I*κ}, {-I*κ, t}}.{a1, b1} &&
b1 == b2*Exp[-I*(2 π)/λ*n*2 π*R], b2]

• That is a weird way to specify a system of quations. Try Solve[{a2, b2} == {{t, -I*\[Kappa]}, {-I*\[Kappa], t}}.{a1, b2*Exp[-I*(2 \[Pi])/\[Lambda]*n*2 \[Pi]*R]}, {a2, b2}] – Henrik Schumacher Sep 24 '17 at 22:19
• It actually makes a lot of sense to specify them separately in the context that I'm using them. If I could, I'd even put a1==1 inside Solve. I don't want to have to manually insert b1 into all the places it will appear. Imagine having 20 equations, what would I do then? – cartonn Sep 24 '17 at 22:40

Another way to do it, maybe not the best way, is the following:

Clear["Global*"]
a1 = 1;
eqs = Thread[{a2, b2} == {{t, -I*κ}, {-I*κ, t}}.{a1, b1}]
AppendTo[eqs, b1 == b2*Exp[-I*(2 π)/λ*n*2 π*R]]
Solve[eqs, {a2, b1, b2}]// Flatten // Last


Solve does not seem to like it when the number of equations is not the same as the number of variables. Sometimes I try to eliminate certain variables myself, like this:

Eliminate[eqs, {a2, b1}]
Solve[%, b2]


This is reasonable behavior for Solve. After all, we have already told Solve that b2 == b1 t - I κ. What more do we want? We have to provide some guidance by specifying the other dependent variables or by eliminating them ourselves.

Although using Eliminate is effective, using Exists as suggested by @jjc385 may be more appealing, especially to us who want to extend our knowledge of Mathematica:

Solve[Exists[{a2, b1}, And @@ eqs], b2]


If we wish to treat a1 as a parameter without assigning a value to it, we can do so like this:

Clear["Global*"]
eqs = Thread[{a2, b2} == {{t, -I*κ}, {-I*κ, t}}.{a1, b1}];
AppendTo[eqs, b1 == b2*Exp[-I*(2 π)/λ*n*2 π*R]];
Solve[Exists[{a2, b1}, And @@ eqs], b2]

• You beat me to it. Can you add the possibility of doing Solve[Exists[{a2,b1}, And@@eqs, b2]? Also, it might be good to mention the second "possible issue" in the docs for Solve, which mentions the issue. +1 – jjc385 Sep 24 '17 at 23:06
• If one is not afraid of undocumented syntax: Solve[eqs, b2, {a2, b1}] – J. M.'s ennui Sep 25 '17 at 5:26

You can use your approach if you ask Solve for {a2, b1, b2}

a1 = 1;
soln1 = Solve[{a2, b2} == {{t, -I*κ}, {-I*κ, t}}.{a1, b1} &&
b1 == b2*Exp[-I*(2 π)/λ*n*2 π*R], {a2, b1, b2}][[1]]

(*  {a2 -> (E^((4 I n π^2 R)/λ) t - t^2 - κ^2)/(
E^((4 I n π^2 R)/λ) - t),
b1 -> -((I κ)/(E^((4 I n π^2 R)/λ) - t)),
b2 -> -((I E^((4 I n π^2 R)/λ) κ)/(
E^((4 I n π^2 R)/λ) - t))}  *)


You can also include a1==1 either directly,

Clear[a1]
soln2 = Solve[
And @@ Thread[{a2, b2} == {{t, -I*κ}, {-I*κ, t}}.{a1, b1}] &&
b1 == b2*Exp[-I*(2 π)/λ*n*2 π*R] && a1 == 1, {a2, b1,
b2}][[1]]

(*  {a2 -> (E^((4 I n π^2 R)/λ) t - t^2 - κ^2)/(
E^((4 I n π^2 R)/λ) - t),
b1 -> -((I κ)/(E^((4 I n π^2 R)/λ) - t)),
b2 -> -((I E^((4 I n π^2 R)/λ) κ)/(
E^((4 I n π^2 R)/λ) - t))}  *)


or as an assumption to Simplify or FullSimplify

soln3 = Solve[
And @@ Thread[{a2, b2} == {{t, -I*κ}, {-I*κ, t}}.{a1, b1}] &&
b1 == b2*Exp[-I*(2 π)/λ*n*2 π*R], {a2, b1, b2}][[1]] //
Simplify[#, a1 == 1] &

(*  {a2 -> -((-E^(((4 I n π^2 R)/λ)) t + t^2 + κ^2)/(
E^((4 I n π^2 R)/λ) - t)),
b1 -> -((I κ)/(E^((4 I n π^2 R)/λ) - t)),
b2 -> -((I E^((4 I n π^2 R)/λ) κ)/(
E^((4 I n π^2 R)/λ) - t))}  *)


Verifying that all three approaches are equivalent

({a2, b1, b2} /. soln1) == ({a2, b1, b2} /. soln2) == ({a2, b1, b2} /.
soln3) // Simplify

(*  True  *)
`