# Transformation Rules [closed]

I've managed to obtain general solutions to a cubic polynomial with arbituary constants (x1, x2, x3 are solutions). By using transformation rules, how would I get x1x2x3,x1x2+x2x3+x3x1 and x1+x2+x3.

See above the result of finding roots of polynomial.

Code: Input:

h[x_] := x^3 + a x^2 + e x + d
s = Solve[h[x] == 0, x]


Output:

{{x -> -(a/3) - (2^(1/3) (-a^2 + 3 e))/(
3 (-2 a^3 - 27 d + 9 a e +
3 Sqrt[3] Sqrt[
4 a^3 d + 27 d^2 - 18 a d e - a^2 e^2 + 4 e^3])^(
1/3)) + (-2 a^3 - 27 d + 9 a e +
3 Sqrt[3] Sqrt[4 a^3 d + 27 d^2 - 18 a d e - a^2 e^2 + 4 e^3])^(
1/3)/(3 2^(1/3))}, {x -> -(a/3) + ((1 + I Sqrt[3]) (-a^2 + 3 e))/(
3 2^(2/3) (-2 a^3 - 27 d + 9 a e +
3 Sqrt[3] Sqrt[
4 a^3 d + 27 d^2 - 18 a d e - a^2 e^2 + 4 e^3])^(
1/3)) - ((1 - I Sqrt[3]) (-2 a^3 - 27 d + 9 a e +
3 Sqrt[3] Sqrt[
4 a^3 d + 27 d^2 - 18 a d e - a^2 e^2 + 4 e^3])^(1/3))/(
6 2^(1/3))}, {x -> -(a/3) + ((1 - I Sqrt[3]) (-a^2 + 3 e))/(
3 2^(2/3) (-2 a^3 - 27 d + 9 a e +
3 Sqrt[3] Sqrt[
4 a^3 d + 27 d^2 - 18 a d e - a^2 e^2 + 4 e^3])^(
1/3)) - ((1 + I Sqrt[3]) (-2 a^3 - 27 d + 9 a e +
3 Sqrt[3] Sqrt[
4 a^3 d + 27 d^2 - 18 a d e - a^2 e^2 + 4 e^3])^(1/3))/(
6 2^(1/3))}}


## closed as off-topic by Daniel Lichtblau, MarcoB, happy fish, Wjx, FeyreApr 2 '17 at 10:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, MarcoB, happy fish, Wjx, Feyre
If this question can be reworded to fit the rules in the help center, please edit the question.

• Sorry, I've just managed to do it. – Alessia T Mar 31 '17 at 18:33
• x1 x2 x3, x1 x2+x2 x3+x3 x1 and x1+x2+x3 are just -d, e and -a. Are you just trying to confirm Vieta's formulas? – Carl Woll Mar 31 '17 at 22:33
• You might want to look at SymmetricPolynomial[]. – J. M. will be back soon Apr 1 '17 at 1:01

h[x_] := x^3 + a x^2 + e x + d
s = Solve[h[x] == 0, x]


Define

sol = x /. s


Then

Total @ sol // FullSimplify


-a

Times @@ sol // FullSimplify


-d

Total @ (Times @@@ Subsets[sol, {2}]) // FullSimplify


e

soln = { {x -> firstSolution}, {x -> secondSolution}, {x3 -> thirdSolution} }


You can extract a list of solutions with

solnList = soln[[ ;;, 1, 2 ]]
(* {firstSolution, secondSolution, thirdSolution} *)


and then turn it into a list of rules with

solnRules = Thread[ {x1, x2, x3} -> solnList ]
(* { x1 -> firstSolution, x2 -> secondSolution, x3 -> thirdSolution } *)


Then you can perform the desired replacements:

x1 x2 x3 /. solnRules
x1 x2 + x2 x3 + x3 x1 /. solnRules
x1 + x2 + x3 /. solnRules


Generalization:

You can generalize this to arbitrarily many solutions with something like

solnList = soln[[ ;;, 1, 2 ]];
solnRules = Thread[ Symbol["x"<>ToString@#]& /@ Range@Length@soln -> solnList ]
(* { x1 -> firstSolution, x2 -> secondSolution, x3 -> thirdSolution } *)


(The last line above can likely be done more elegantly, possibly using MapIndexed rather than Thread.)

Edit As mentioned, a (marginally) more elegant solution:

solnList = soln[[ ;;, 1, 2 ]];
MapIndexed[Symbol["x" <> ToString@First@#2] -> #1 &, solnList]
(* { x1 -> firstSolution, x2 -> secondSolution, x3 -> thirdSolution } *)

• I'm trying to transpose my list of solutions, but it's not evaluating the values of x that was outputted. – Alessia T Mar 31 '17 at 18:31
• @AlessiaT Could you be more specific and post the code and output? The best way to do this is to edit the question. – jjc385 Mar 31 '17 at 18:33
• @AlessiaT Just to be clear, by 'transposed list of solutions, I was referring to the way Solve` outputs it. (The output looks like a column matrix, which is why I referred to it as 'transposed'.) – jjc385 Mar 31 '17 at 18:39
• I've been trying to do this part for a while now, and tried inputting the transposed list into mathematica again, but managed to do it now! thank you so much, very appreciative!! – Alessia T Mar 31 '17 at 18:44
• @AlessiaT You're welcome, but the best way to thank me is to upvote and (after some time passes to allow others to answer) to accept my answer. – jjc385 Mar 31 '17 at 18:49