Question

Why does this not work?

In: from sympy import *

    x = symbols('x', real=True)
    f = symbols('f', cls=Function, real=True)
    simplify(f(x)*conjugate(f(x)))

Out: f(x)*conjugate(f(x))

I expected f(x)**2.

Was it helpful?

Solution

Unfortunately, functions created with Function ignore assumptions. You'll need to create a function by subclassing Function, like

In [12]: class f(Function):
   ....:     is_real=True
   ....:

In [13]: f(x)
Out[13]: f(x)

In [14]: f(x).conjugate()
Out[14]: f(x)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top