# Efficient code for solve this equation

We have $a*b*c=-1$, $\frac{a^2}{c}+\frac{b}{c^2}=1$, $a^2 b+a c^2+b^2 c=t$

What's the value of $a^5 c+a b^5+b c^5$?

I tried

Eliminate[{a b c == -1, a^2/c + b/c^2 == 1, a^2 b + b^2 c + c^2 a == t,
a b^5 + b c^5 + c a^5 == res}, {a, b, c}]


It's much slower than Maple's eliminate. How do I solve this efficiently?

-
You can try to solve first and then evaluate? sol = Solve[{a b c == -1, a^2/c + b/c^2 == 1, a^2 b + b^2 c + c^2 a == t}, {a, b, c}] Evaluate[a b^5 + b c^5 + c a^5 /. sol[[1]]] I am not sure if this is the type of result you are looking for. –  BarisV Mar 11 '13 at 12:59
@BarisV Thansks. I tried this, but to simplify it is so slow. –  chyaong Mar 11 '13 at 13:35

If you use the third argument in Solve, i.e. a list of variables to be eliminated (take a look at the Eliminating Variables tutorial in Mathematica) then you'll get the result immediately :

Solve[{a b c == -1, a^2/c + b/c^2 == 1,
a^2 b + b^2 c + c^2 a == t,
a b^5 + b c^5 + c a^5 == res},
{res}, {a, b, c, t}]

{{res -> 3}}


Edit

It should be underlined that Solve appears to be smarter than Eliminate due to its improvement in Mathematica 8, look at its options, e.g. MaxExtraConditions, Method ( Method -> Reduce). However most of the update of Solve is hidden, but in general it shares its methods with Reduce. Defining

system = { a b c == -1,
a^2/c + b/c^2 == 1,
a^2 b + b^2 c + c^2 a == t,
a b^5 + b c^5 + c a^5 == res };


then it works too

Solve[ system, {res}, {a, b, c}]

{{res -> 3}}


while it doesn't in Mathematica 7 yielding

No more memory available.
Mathematica kernel has shut down.
Try quitting other applications and then retry.


and your original problem should be evaluated this way (you've lost t):

Eliminate[ system, {a, b, c, t}]

res == 3


and it works in Mathematica 7 as well.

-

Can compute a Groebner basis with an ordering that eliminates {a,b,c}.

eqns = {a b c == -1, a^2/c + b/c^2 == 1, a^2 b + b^2 c + c^2 a == t,
a b^5 + b c^5 + c a^5 == res};
GroebnerBasis[
Numerator[Together[Apply[Subtract, eqns, {1}]]], {res, t}, {a, b, c}]

(* Out[150]= {-3 + res} *)


The result is now immediate.

-

I found two methods:

Reduce[{a b c == -1, a^2/c + b/c^2 == 1, a^2 b + b^2 c + c^2 a == t,
a b^5 + b c^5 + c a^5 == res}, {t}] // First
(*res == 3*)

res /. Solve[{a b c == -1, a^2 + b/c == c, a^2 b + b^2 c + c^2 a == t,
a b^5 + b c^5 + c a^5 == res}, {a, b, c, res}] // Union
(*{3}*)

-
In general, this way is recommended : res /. {ToRules @ Reduce[{a b c == -1, a^2/c + b/c^2 == 1, a^2 b + b^2 c + c^2 a == t, a b^5 + b c^5 + c a^5 == res}, {t}]}. We can observe that we do not need this equation : a^2 b + b^2 c + c^2 a == t, i.e. we can get the solution this way res /. {ToRules @ Reduce[{a b c == -1, a^2/c + b/c^2 == 1, a b^5 + b c^5 + c a^5 == res}, {res}]}. –  Artes Mar 11 '13 at 18:46
You can do also this Normal @ Solve[{a b c == -1, a^2/c + b/c^2 == 1, a b^5 + b c^5 + c a^5 == res}, {res}, MaxExtraConditions -> All]  –  Artes Mar 11 '13 at 18:53
@Artes Thansk you very much. –  chyaong Mar 12 '13 at 3:13