Sympy: Conjugate Real Functions

Why is this not working?

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 was expecting f(x)**2.

+4
source share
1 answer

Unfortunately, functions created with help Functionignore assumptions. You will need to create a function by subclassing Functione.g.

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)
+2
source

Source: https://habr.com/ru/post/1534777/


All Articles