# Dealing with functional equations

I have the specific function $G$ of $x$ satisfying the functional equation $G^3x=-1+G(1-x)+G^2x$. By using Mathematica, I would like to simplify the following polynomial of $G$ and $x$.

$2 G^2 + 6 G^2 x + 4 G^3 x + 3 G^2 x^2 - 8 G^3 x^2 - 2 G^4 x^2$

Because of the given relation, we should be able to substitute $G^3x$, and express the above as the polynomial with $G^n$, $x^i$, $Gx^j$, and $G^2x^k$ terms. Mathematica does not allow the assignment of a power, so I cannot figure out the reasonable way of doing this.

Is there any efficient method to solve this by using Mathematica?

• Actually, I think Mathematica would allow "the assignment of a power". For example Power[G, 3] ^= .... Look up UpValues and TagSet in the docs. – LLlAMnYP May 7 '15 at 11:57

In its core, an assignment in Mathematica is always just a replacement rule. If I understood you correctly, then the solution to your problem is to simply use replacement rules instead of trying to assign your first equation.

Let me show you what I mean:

g3expr = -1 + G (1 - x) + G^2 x;
poly = 2 G^2 + 6 G^2 x + 4 G^3 x + 3 G^2 x^2 - 8 G^3 x^2 - 2 G^4 x^2;


I just stored your polynomial and the expression for $G^3x$ in a variable. Now we will do the replacement by ourselves:

poly /. {G^3 x :> g3expr, G^3 x^2 :> x*g3expr}
ExpandAll[%]


which gives you

$$-2 G^4 x^2-5 G^2 x^2+10 G^2 x+2 G^2+8 G x^2-12 G x+4 G+8 x-4$$

Note that you need to pay attention because replacements depend on the exact structure of the expression you try to substitute. Therefore, something like $G^3x^3$ is not automatically considered to be $G^3x\cdot x$ which is the reason why I had a separate rule to replace this G^3 x^2 :> x*expr.

• you mean of course g3expr in the second code block? – LLlAMnYP May 7 '15 at 9:59
• @LLlAMnYP This happens when you hack it down and then decide to give meaningful names for the answer :-) Thanks for noticing it, I fixed it. – halirutan May 7 '15 at 10:01