Simplify fog type function chain using sympy

105 Views Asked by At

I need to simplify some lengthy $fog(x)$ where both $f(x)$ and $g(x)$ are known rational polynomial in one variable.

For e.g. $f(x) = (7x-9)/12$ and $g(x) = (2x-5)/7$. Then I would like to get a simplified rational expression of $f(f(g(f(g(g(f(x)))))))$.

I would like to do this in sympy if possible. Looked through sympy docs, but might have overlooked something related to such chained function simplification. If not possible in sympy then any other free CAS is preferred. The function chain is quite lengthy, hence would like to use a CAS.

Thanks for the help.

1

There are 1 best solutions below

2
On BEST ANSWER

In sagemath,

  f(x)=12*x+10
  g(x)=12*x^2+10*x+1
  simplify(f(g(g(f(g(x)))))).show()

Does the job. It will be similar in mathematica.