# How to solve two simultaneous equations provided that one of the variables cannot take values of integer multiples of Pi?

I would like to solve these two simultaneous equations for $E_p(k)$ provided that $p\neq \pm n\pi$, where $n$ is an integer:

3 K*d^2 + Sqrt[C1^2 + 4*C2^2*Cos[k/2]^2 + 4*C1*C2*Cos[k/2]*Cos[p]]==Ep;
C1*Sin[p*n] + 2*C2*Cos[k/2]*Sin[p*(n + 1)]==0;


I've tried declaring $p\neq \pm n\pi$ within an NSolve in place of inequalities and I've tried deleting the undesired $p$ values posthumously using DeleteCases, both to no avail. Here are the constants used too:

n = 3;
t = 2.5;
a = 6.31;
K = 49.7;
d = 0.1;
C1 = -t - 2*a*d;
C2 = -t + a*d;


Any help would be greatly appreciated, thanks!

• From the docs of NSolve: "NSolve deals primarily with linear and polynomial equations." It is basically a numerical version of Solve, trying to find all possible solutions to (sets of) polynomial equations. Of course it can handle some other types of equations, but few general cases. Try with FindInstance or FindRoot instead, or just to be sure, Solve but with exact coefficients (497/10 instead of 49.7 etc.) – Marius Ladegård Meyer Dec 5 '16 at 22:19
• Note though that if you demand the Sqrt in the fist equation to be real, then you can move 3 K*d^2 to the RHS, square both sides, and isolate Cos[p]... – Marius Ladegård Meyer Dec 5 '16 at 22:20
• Thank you very much for the speedy reply! I tried all the things you've suggested and solutions are indeed missing when it comes to plotting $E_{\pm}(k)$. What I don't understand is that when I set $d=0$ and $t=1$ I obtain the required results as long as I specify that $p\neq0$, $p\neq-\pi$ and $p\neq\pi$. So surely then I can extend it to having more coefficients (as in this case)? Why would that suddenly make it unsolvable? – TSmith Dec 6 '16 at 11:31

This?

Simplify[Reduce[{3 K*d^2+Sqrt[C1^2+4*C2^2*Cos[k/2]^2+4*C1*C2*Cos[k/2]*Cos[p]]==Ep,
C1*Sin[p*n]+2*C2*Cos[k/2]*Sin[p*(n+1)]==0, Sin[n p]!=0, Sin[p*(n+1)]!=0,
n \[Element] Integers}, {Ep, k}] //.
{n->3, t->2.5, a->6.31, K->49.7, d->0.1, C1-> -t-2*a*d, C2-> -t+a*d},
Sin[3 p]!=0 && Sin[4 p]!=0]


which gives you

(* C \[Element] Integers &&
Ep == 1.491+1.881 Sqrt[1/(Cos[p]+Cos[3 p])^2] &&
(k==4 \[Pi] C+2 ArcCos[-1.00642 Csc[4 p] Sin[3 p]] ||
k==4 \[Pi] C-2 ArcCos[-1.00642 Csc[4 p] Sin[3 p]])
*)

• Thanks for the speedy reply! I can't believe I didn't think of using $sin[p n]\neq0$ instead of $p\neq0$... I'm looking for $E$ as a function of $k$ and not of $p$, but I tried using this with {Ep,p} instead but there were issues. Taking some of what you've done into account I wrote this: m \[Element] Integers; rootsp = NSolve[{Fp[c, p] == Ep, F[c, p] == 0, Sin[p*m] != 0, Sin[p*(m + 1)] != 0}, {Ep, p}]; p1 = Plot[Ep /. rootsp, {c, -Pi, Pi}]; It didn't work and the undesired values were still there! I simply don't understand why it's ignoring the inequations bit... – TSmith Dec 6 '16 at 11:41