2
$\begingroup$

I'm currently working on the Polya's Enumeration Theorem implementation in Mathematica. As an example, of what I want to do, here's a formula I'm working with:

$$P_{C_{12}}(x_1,\ldots,x_{12})=\frac{1}{12}\left(x^{12}_1+x^{6}_2+2x^{4}_3+2x^{3}_4+2x^{2}_6+4x^{1}_{12}\right)$$

I'd like to replace $x_i$ with another expression that involves $i$, $w^i+b^i$, and then simplify the whole expression. How could I do that?

$\endgroup$
4
$\begingroup$

The implementation depends on how you define your variables. I have used x[i] as an expression for $x_i$.

P = (1/12) (x[1]^12 + x[2]^6 + 2 x[3]^4 + 2 x[4]^3 + 2 x[6]^2 + 
    4 x[12]^1);

P2 = P /. x[i_] -> w^i + b^i
(* 1/12 ((b + w)^12 + (b^2 + w^2)^6 + 2 (b^3 + w^3)^4 + 
   2 (b^4 + w^4)^3 + 2 (b^6 + w^6)^2 + 4 (b^12 + w^12)) *)

P2 // Expand
(* b^12 + b^11 w + 6 b^10 w^2 + 19 b^9 w^3 + 43 b^8 w^4 + 66 b^7 w^5 + 
 80 b^6 w^6 + 66 b^5 w^7 + 43 b^4 w^8 + 19 b^3 w^9 + 6 b^2 w^10 + 
 b w^11 + w^12 *)
$\endgroup$
2
  • $\begingroup$ Thank you, that was exactly what I was looking for. As a side note, is it possible to keep x's with subscripts and do something similar? $\endgroup$ Jul 26 at 13:41
  • 1
    $\begingroup$ You mean like this? P = 1/12 (Subscript[x, 1]^12 + Subscript[x, 2]^6 + 2*Subscript[x, 3]^4 + 2*Subscript[x, 4]^3 + 2*Subscript[x, 6]^2 + 4*Subscript[x, 12]); P2 = P /. Subscript[x, i_] -> w^i + b^i $\endgroup$
    – Domen
    Jul 26 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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