Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have two problems which I'd like to solve with Mathematica.

If I have a system of two equations with three unknowns, how can I get to list all possible solutions for the unknowns?

Here is what I have tried:

Solve[{ a + b + c == 5, 1/a + 1/b + 1/c == 1/5}, { a, b, c}]
Solve::svars: Equations may not give solutions for all "solve" variables. >> 

{{a -> 5, c -> -b}, {b -> 5, c -> -a}, {b -> -a, c -> 5}}

What would I change in this specific instance?

Here are the problems:


Suppose that $a, b, c$ are real numbers satisfying $a+b+c=5$ and $\frac{1}{a}+\frac{1}{b}+\frac{1}{c}=+\frac{1}{5}$.
Find the greatest possible value of $a^3+b^3+c^3$

If I list all solutions I'll be able to choose all solutions maximizing $a^3+b^3+c^3$.


Finding integers $x, y$ and $z$ that satisfy this system:
$$\quad x^2 y + y^2 z + z^2 x = 2186 $$
$$\quad x y^2 + y z^2 + z x^2 = 2188$$.
evaluate $x^2+y^2+z^2$

The both problems can be found here (see exercises $27$ and $30$ ).

share|improve this question

marked as duplicate by m_goldberg, bobthechemist, Dr. belisarius, ciao, Silvia Apr 8 '14 at 5:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

I have asked a specific question. Please let me know if you can help. @Artes – user140900 Apr 7 '14 at 0:33
@Artes Is there a way to get a list of exact values instead of conditions? Also, Reduce does not seem to work. – user140900 Apr 7 '14 at 0:40
Reduce works well, in any case you should study this post How do I make Reduce yield all solutions explicitly?. – Artes Apr 7 '14 at 0:48
Thanks. That helps a lot. – user140900 Apr 7 '14 at 0:51
@Artes How would I find the number of unknowns that satisfy certain conditions? – user140900 Apr 7 '14 at 1:44
up vote 5 down vote accepted


Let's write down an appropriate system we would like to solve,
i.e. we are to maximize a^3 + b^3 + c^3 knowing that a + b + c == 5 and 1/a + 1/b + 1/c == 1/5, thus the most direct approach uses Maximize with adequate conditions:

Maximize[{a^3 + b^3 + c^3, a + b + c == 5, 1/a + 1/b + 1/c == 1/5}, {a, b, c}]
{125, {a -> 1, b -> 5, c -> -1}}

With Maximize we can get only a specific solution, an example can be found here : How do I determine the maximum value for a polynomial, given a range of x values?, nevertheless we can remedy this problem using Lagrange multipliers, see e.g. How can I implement the method of Lagrange multipliers to find constrained extrema?.
However since there is a symmetry between a, b and c we can conclude that any permutation of this triple {a -> 1, b -> 5, c -> -1} is also a solution.

There are another ways to solve the problem which can be examined with the answers to these questions: Am I missing anything? Solving Equations
Efficient code for solve this equation

Let's provide the simplest:

Simplify[ a^3 + b^3 + c^3, {{a + b + c == 5, 1/a + 1/b + 1/c == 1/5}}]


Another question provides a nice example where a simple usage of Solve and Reduce with an appropriate domain specification will not be sufficient.

E.g. this yields a complicated system returning the solution but it doesn't clarify if another solutions really exist.

Reduce[ x^2 y + y^2 z + z^2 x == 2186 && x y^2 + y z^2 + z x^2 == 2188 && 
        (x | y | z) ∈ Integers, {x, y, z}]

Thus we should approach the problem in a different way.
Let's notice that:

Simplify[ x y^2 + y z^2 + z x^2 - (x^2 y + y^2 z + z^2 x)]
-(x - y) (x - z) (y - z)

Now we can conclude that using slightly different system we can find an appropriate solution:

 x^2 + y^2 + z^2 /. Normal @ 
 Solve[ x - y == a && x - z == b && y - z == c && 
        x^2 y + y^2 z + z^2 x == 2186 && -a b c == 2, {x, y, z}, Integers]//Union//First
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.