1
$\begingroup$

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.code

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))}}
$\endgroup$

closed as off-topic by Daniel Lichtblau, MarcoB, happy fish, Wjx, Feyre Apr 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.

  • 1
    $\begingroup$ Sorry, I've just managed to do it. $\endgroup$ – Alessia T Mar 31 '17 at 18:33
  • 2
    $\begingroup$ 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? $\endgroup$ – Carl Woll Mar 31 '17 at 22:33
  • $\begingroup$ You might want to look at SymmetricPolynomial[]. $\endgroup$ – J. M. will be back soon Apr 1 '17 at 1:01
2
$\begingroup$
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

$\endgroup$
0
$\begingroup$

If you start with 'transposed' list of solutions,

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 } *)
$\endgroup$
  • $\begingroup$ I'm trying to transpose my list of solutions, but it's not evaluating the values of x that was outputted. $\endgroup$ – Alessia T Mar 31 '17 at 18:31
  • $\begingroup$ @AlessiaT Could you be more specific and post the code and output? The best way to do this is to edit the question. $\endgroup$ – jjc385 Mar 31 '17 at 18:33
  • $\begingroup$ @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'.) $\endgroup$ – jjc385 Mar 31 '17 at 18:39
  • $\begingroup$ 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!! $\endgroup$ – Alessia T Mar 31 '17 at 18:44
  • $\begingroup$ @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. $\endgroup$ – jjc385 Mar 31 '17 at 18:49

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