Solve polynomial with a condition

I need to get algebraic expression for r by solving the polynomial mention below with a condition, the condition is that [Lambda]<=0.

I used solve command and set the polynomial equal to 0 and add the condition to the command.

The code is like this:

Solve[\[Lambda]^3 + (
128 (9 (1 +
3 alpha) \[Pi] (2 (1 + alpha) k^2 + (7 +
19 alpha) \[Pi]^2) +
Ha^2 (18 (2 + \[Pi]) +
alpha (108 + 37 \[Pi] - 14 \[Pi]^2 +
6 \[Pi]^3))) \[Lambda]^2)/(
9 (1 + 3 alpha) \[Pi] (k^2 + \[Pi]^2)) +
1/(81 (1 + 3 alpha)^2 \[Pi]^4 (k^2 + \[Pi]^2)^2)
4 (1296 (1 +
3 alpha)^2 \[Pi]^4 (k^4 (1 + 2 alpha + alpha^2 - 2 r) +
2 k^2 \[Pi]^2 (6 + 23 alpha + 17 alpha^2 -
2 r) + \[Pi]^4 (15 + 78 alpha + 99 alpha^2 - 2 r)) +
Ha^4 (288 (36 + 173 alpha + 195 alpha^2) \[Pi]^3 +
16 alpha (-36 + 193 alpha) \[Pi]^5 - 1344 alpha^2 \[Pi]^7 -
81 k^4 r - 27 k^2 (6 + k^2) \[Pi]^2 r -
27 \[Pi]^6 (-32 alpha + 3712 alpha^2 + r) +
9 \[Pi]^4 (144 + 664 alpha + 316 alpha^2 - 9 r -
6 k^2 r)) +
36 (1 + 3 alpha) Ha^2 \[Pi]^2 (3 k^4 (9 +
2 \[Pi]^2) r + \[Pi]^3 (864 +
24 alpha (204 + 71 \[Pi] - 14 \[Pi]^2 + 3 \[Pi]^3) +
4 alpha^2 (1728 + 583 \[Pi] - 224 \[Pi]^2 +
42 \[Pi]^3) + 6 \[Pi]^3 r + 27 \[Pi] (12 + r)) +

2 k^2 \[Pi] (alpha^2 (432 + 85 \[Pi] - 56 \[Pi]^2 +
24 \[Pi]^3) +
alpha (576 + 139 \[Pi] - 56 \[Pi]^2 + 24 \[Pi]^3) +
3 (48 + 2 \[Pi]^3 r + 9 \[Pi] (2 + r))))) \[Lambda] +
1/(486 (1 +
3 alpha)^4 \[Pi]^5 (k^2 + \[Pi]^2)^3) (-648 (1 +
3 alpha)^4 \[Pi]^5 -
18 Ha^2 (\[Pi] + 3 alpha \[Pi])^2 (9 (16 + \[Pi]) +
alpha (432 + 19 \[Pi] - 56 \[Pi]^2 + 6 \[Pi]^3)) +
Ha^4 (-648 - 9 alpha (224 + 9 \[Pi] + 20 \[Pi]^2) +
alpha^2 (-216 - 9 \[Pi] - 1268 \[Pi]^2 + 12906 \[Pi]^3 +
168 \[Pi]^4))) (-48 (1 +
3 alpha)^2 \[Pi]^4 (k^2 (1 + 2 alpha + alpha^2 -
2 r) + \[Pi]^2 (1 + 4 alpha + 3 alpha^2 - 2 r)) +
Ha^4 (3 + \[Pi]^2) (k^2 + \[Pi]^2) r -
4 (1 + 3 alpha) Ha^2 \[Pi]^2 (9 k^2 r +
2 \[Pi]^4 r + \[Pi]^2 (12 + 54 alpha + 42 alpha^2 + 9 r +
2 k^2 r))) == 0 && \[Lambda] <= 0, r]

The problem is that when I run the code, It run for infinite time and I don't receive any answer.

I will appreciate any help and comment.

• The function seems to be linear in r; Solve[] for it first, and then use Simplify[expr, λ <= 0] – J. M.'s technical difficulties Nov 5 '17 at 11:23

{{r -> -((6 (1 +
3 \[Alpha]) \[Pi]^4 (-4 Ha^6 (-1296 -
18 \[Alpha] (548 + 9 \[Pi] + 20 \[Pi]^2) +
18 \[Alpha]^3 (-892 - 36 \[Pi] - 704 \[Pi]^2 +
6453 \[Pi]^3 + 84 \[Pi]^4) +
7 \[Alpha]^4 (-216 - 9 \[Pi] - 1268 \[Pi]^2 +
12906 \[Pi]^3 + 168 \[Pi]^4) +
\[Alpha]^2 (-23112 - 747 \[Pi] - 4156 \[Pi]^2 +
25812 \[Pi]^3 + 336 \[Pi]^4)) +
81 (1 + 3 \[Alpha])^3 \[Pi] (k^6 \[Lambda] (64 + 64 \[Alpha]^2 +
256 \[Lambda] + \[Lambda]^2 +
128 \[Alpha] (1 + 2 \[Lambda])) +
k^4 \[Pi]^2 \[Lambda] (832 + 2240 \[Alpha]^2 +
1408 \[Lambda] + 3 \[Lambda]^2 +
128 \[Alpha] (24 + 23 \[Lambda])) + \[Pi]^6 (64 +
3456 \[Alpha]^3 + 1728 \[Alpha]^4 + 960 \[Lambda] +
896 \[Lambda]^2 + \[Lambda]^3 +
576 \[Alpha]^2 (4 + 11 \[Lambda]) +
128 \[Alpha] (5 + 39 \[Lambda] + 19 \[Lambda]^2)) +
k^2 \[Pi]^4 (64 + 1536 \[Alpha]^3 + 576 \[Alpha]^4 +
1728 \[Lambda] + 2048 \[Lambda]^2 + 3 \[Lambda]^3 +
64 \[Alpha]^2 (22 + 133 \[Lambda]) +
256 \[Alpha] (2 + 31 \[Lambda] + 20 \[Lambda]^2))) -
8 (1 + 3 \[Alpha]) Ha^4 (2 \[Pi]^2 (3 \[Alpha]^4 (-13716 -
603 \[Pi] + 1130 \[Pi]^2 + 6264 \[Pi]^3 +
84 \[Pi]^4) +
\[Alpha]^3 (-83160 - 3897 \[Pi] + 5762 \[Pi]^2 +
24894 \[Pi]^3 + 336 \[Pi]^4) -
81 (20 + \[Pi] + 32 \[Lambda] + 4 \[Pi] \[Lambda]) -
9 \[Alpha] (6 \[Pi]^3 (1 + 4 \[Lambda]) -
2 \[Pi]^2 (23 + 8 \[Lambda]) + \[Pi] (91 +
166 \[Lambda]) + 8 (221 + 173 \[Lambda])) +
\[Alpha]^2 (\[Pi]^2 (2786 - 772 \[Lambda]) +
84 \[Pi]^4 (1 + 4 \[Lambda]) +
864 \[Pi]^3 (7 + 29 \[Lambda]) -
9 \[Pi] (314 + 79 \[Lambda]) -
72 (782 + 195 \[Lambda]))) +
k^2 (\[Alpha]^4 (-216 - 9 \[Pi] - 1268 \[Pi]^2 +
12906 \[Pi]^3 + 168 \[Pi]^4) +
\[Alpha]^3 (-2448 - 99 \[Pi] - 2716 \[Pi]^2 +
25812 \[Pi]^3 + 336 \[Pi]^4) -
648 (1 + (8 + \[Pi]) \[Lambda]) -
9 \[Alpha] (368 + 2768 \[Lambda] +
48 \[Pi]^3 \[Lambda] -
4 \[Pi]^2 (-5 + 8 \[Lambda]) + \[Pi] (9 +
332 \[Lambda])) +
\[Alpha]^2 (168 \[Pi]^4 (1 + 4 \[Lambda]) -
9 \[Pi] (19 + 158 \[Lambda]) -
144 (34 + 195 \[Lambda]) -
4 \[Pi]^2 (407 + 386 \[Lambda]) +
54 \[Pi]^3 (239 + 928 \[Lambda])))) +
144 (Ha +
3 \[Alpha] Ha)^2 (2 k^4 \[Lambda] (\[Alpha]^2 (432 +
85 \[Pi] - 56 \[Pi]^2 + 24 \[Pi]^3) +
18 (8 + 3 \[Pi] + 8 \[Lambda] + 4 \[Pi] \[Lambda]) +
\[Alpha] (-56 \[Pi]^2 (1 + \[Lambda]) +
24 \[Pi]^3 (1 + \[Lambda]) +
144 (4 + 3 \[Lambda]) + \[Pi] (139 +
148 \[Lambda]))) + \[Pi]^4 (9 \[Alpha]^4 (432 +
145 \[Pi] - 56 \[Pi]^2 + 6 \[Pi]^3) +
6 \[Alpha]^3 (1296 + 430 \[Pi] - 140 \[Pi]^2 +
15 \[Pi]^3) +
2 \[Alpha]^2 (21 \[Pi]^3 (1 + 4 \[Lambda]) +
864 (3 + 4 \[Lambda]) -
28 \[Pi]^2 (7 + 16 \[Lambda]) + \[Pi] (845 +
1166 \[Lambda])) +
9 (16 (1 + 6 \[Lambda] + 2 \[Lambda]^2) + \[Pi] (5 +
36 \[Lambda] + 16 \[Lambda]^2)) +
2 \[Alpha] (-28 \[Pi]^2 (1 + 6 \[Lambda] +
2 \[Lambda]^2) +
144 (5 + 17 \[Lambda] + 3 \[Lambda]^2) +
3 \[Pi]^3 (1 + 12 \[Lambda] + 8 \[Lambda]^2) +
2 \[Pi] (115 + 426 \[Lambda] + 74 \[Lambda]^2))) +
k^2 \[Pi]^2 (3 \[Alpha]^4 (432 + 19 \[Pi] - 56 \[Pi]^2 +
6 \[Pi]^3) +
2 \[Alpha]^3 (1728 + 80 \[Pi] - 196 \[Pi]^2 +
21 \[Pi]^3) +
9 (16 + \[Pi] + 128 \[Lambda] + 48 \[Pi] \[Lambda] +
64 \[Lambda]^2 + 32 \[Pi] \[Lambda]^2) +
2 \[Alpha]^2 (-28 \[Pi]^2 (5 + 18 \[Lambda]) +
144 (11 + 27 \[Lambda]) +
3 \[Pi]^3 (5 + 36 \[Lambda]) + \[Pi] (79 +
1251 \[Lambda])) +
2 \[Alpha] (-28 \[Pi]^2 (1 + 8 \[Lambda] +
4 \[Lambda]^2) +
144 (4 + 21 \[Lambda] +
6 \[Lambda]^2) + \[Pi]^3 (3 + 60 \[Lambda] +
48 \[Lambda]^2) + \[Pi] (32 + 991 \[Lambda] +
296 \[Lambda]^2))))))/((k^2 + \[Pi]^2) (-96 (1 +
3 \[Alpha])^2 \[Pi]^4 - Ha^4 (3 + \[Pi]^2) +
4 (1 + 3 \[Alpha]) Ha^2 \[Pi]^2 (9 +
2 \[Pi]^2)) (18 Ha^2 (\[Pi] +
3 \[Alpha] \[Pi])^2 (9 (16 + \[Pi]) +
\[Alpha] (432 + 19 \[Pi] - 56 \[Pi]^2 + 6 \[Pi]^3)) +
Ha^4 (648 + 9 \[Alpha] (224 + 9 \[Pi] + 20 \[Pi]^2) +
\[Alpha]^2 (216 + 9 \[Pi] + 1268 \[Pi]^2 - 12906 \[Pi]^3 -
168 \[Pi]^4)) +
648 (1 + 3 \[Alpha])^2 \[Pi] (k^4 \[Lambda] +
2 k^2 \[Pi]^2 \[Lambda] + \[Pi]^4 (1 + 6 \[Alpha] +
9 \[Alpha]^2 + \[Lambda])))))}}

Your equation eqn==0 seems to be comprised of fractions. Thus, use Together, and then extract the Numerator, because it should be equal to 0 for your solution.

Now, inspect your Numerator as a polynomial in $r$ using CoefficientList or Exponent. So:

Exponent[Numerator@Together@eqn, r]

(* 1 *)

So your Numerator is linear in $r$. Then your solution will be the division between the two elements of the CoefficientList:

(#[[1]]/#[[2]]) & /@ {CoefficientList[Numerator@Together@eqn, r]}

You could even FullSimplify your result after a couple of minutes:

{(6 (1 + 3 alpha) \[Pi]^4 (4 (1 + alpha) (2 + 7 alpha) Ha^6 (648 +
alpha (2016 + 216 alpha + 9 \[Pi] (9 + 20 \[Pi]) +
alpha \[Pi] (9 -
2 \[Pi] (-634 + 6453 \[Pi] + 84 \[Pi]^2)))) +
81 (1 + 3 alpha)^3 \[Pi] (64 (1 + alpha) (1 +
3 alpha)^2 \[Pi]^4 ((1 + alpha) k^2 + (1 +
3 alpha) \[Pi]^2) +
64 (k^2 + \[Pi]^2) ((1 + alpha)^2 k^4 +
2 (1 + alpha) (6 + 17 alpha) k^2 \[Pi]^2 +
3 (1 + 3 alpha) (5 + 11 alpha) \[Pi]^4) \[Lambda] +
128 (k^2 + \[Pi]^2)^2 (2 (1 + alpha) k^2 + (7 +
19 alpha) \[Pi]^2) \[Lambda]^2 + (k^2 + \[Pi]^2)^3 \
\[Lambda]^3) -
8 (1 + 3 alpha) Ha^4 (2 \[Pi]^2 ((1 + alpha) (1 +
3 alpha) (-81 (20 + \[Pi]) +
alpha (-9432 - 13716 alpha -
9 \[Pi] (55 - 46 \[Pi] + 6 \[Pi]^2) +
alpha \[Pi] (-603 +
2 \[Pi] (565 +
6 \[Pi] (522 + 7 \[Pi]))))) + (-324 (8 + \[Pi]) -
18 alpha (692 + \[Pi] (83 + 4 \[Pi] (-2 + 3 \[Pi]))) +
alpha^2 (-14040 + \[Pi] (-711 +
4 \[Pi] (-193 +
12 \[Pi] (522 + 7 \[Pi]))))) \[Lambda]) +
k^2 ((1 + alpha)^2 (-648 -
9 alpha (224 + \[Pi] (9 + 20 \[Pi])) +
alpha^2 (-216 + \[Pi] (-9 +
2 \[Pi] (-634 + 6453 \[Pi] + 84 \[Pi]^2)))) +
2 (-324 (8 + \[Pi]) -
18 alpha (692 + \[Pi] (83 + 4 \[Pi] (-2 + 3 \[Pi]))) +
alpha^2 (-14040 + \[Pi] (-711 +
4 \[Pi] (-193 +
12 \[Pi] (522 + 7 \[Pi]))))) \[Lambda])) +
144 (Ha +
3 alpha Ha)^2 (\[Pi]^4 ((1 + alpha) (1 +
3 alpha)^2 (9 (16 + 5 \[Pi]) +
alpha (432 + \[Pi] (145 - 56 \[Pi] + 6 \[Pi]^2))) +
4 (72 (1 + 3 alpha) (3 + 8 alpha) + (81 +
alpha (426 + 583 alpha)) \[Pi] -
28 alpha (3 + 8 alpha) \[Pi]^2 +
6 alpha (3 + 7 alpha) \[Pi]^3) \[Lambda] +
8 (18 (2 + \[Pi]) +
alpha (108 + \[Pi] (37 +
2 \[Pi] (-7 + 3 \[Pi])))) \[Lambda]^2) +
k^2 \[Pi]^2 ((1 + alpha)^2 (1 + 3 alpha) (9 (16 + \[Pi]) +
alpha (432 + \[Pi] (19 - 56 \[Pi] + 6 \[Pi]^2))) +
2 (72 (8 + 3 \[Pi]) +
alpha (3024 + \[Pi] (991 + 4 \[Pi] (-56 + 15 \[Pi])) +
9 alpha (432 + \[Pi] (139 +
4 \[Pi] (-14 + 3 \[Pi]))))) \[Lambda] +
16 (18 (2 + \[Pi]) +
alpha (108 + \[Pi] (37 +
2 \[Pi] (-7 + 3 \[Pi])))) \[Lambda]^2) +
2 k^4 \[Lambda] (alpha^2 (432 + \[Pi] (85 +
8 \[Pi] (-7 + 3 \[Pi]))) +
18 (8 + 3 \[Pi] + 4 (2 + \[Pi]) \[Lambda]) +
alpha (144 (4 + 3 \[Lambda]) + \[Pi] (139 +
148 \[Lambda] +
8 \[Pi] (-7 +
3 \[Pi]) (1 + \[Lambda])))))))/((k^2 + \[Pi]^2) \
(-96 (1 + 3 alpha)^2 \[Pi]^4 - Ha^4 (3 + \[Pi]^2) +
4 (1 + 3 alpha) Ha^2 \[Pi]^2 (9 + 2 \[Pi]^2)) (18 Ha^2 (\[Pi] +
3 alpha \[Pi])^2 (9 (16 + \[Pi]) +
alpha (432 + \[Pi] (19 - 56 \[Pi] + 6 \[Pi]^2))) +
Ha^4 (648 +
alpha (2016 + 216 alpha + 9 \[Pi] (9 + 20 \[Pi]) +
alpha \[Pi] (9 -
2 \[Pi] (-634 + 6453 \[Pi] + 84 \[Pi]^2)))) +
648 (1 +
3 alpha)^2 \[Pi] ((1 +
3 alpha)^2 \[Pi]^4 + (k^2 + \[Pi]^2)^2 \[Lambda])))}

These steps take no so much time in an Intel i3.