# Assume a function is real-valued

In the following expression:

var('z')

u = function('u')(z)
v = function('v')(z)

f = u + i * v

show(f.diff(z).conjugate().expand().simplify_full())
# conjugate(diff(u(z), z)) - I*conjugate(diff(v(z), z))


I would like Sage to make the simplification conjugate(diff(u(z), z)) = diff(u(z), z) because $u, v$ are intended to be real-valued. But my first attempt:

assume(u, 'real')


didn't work:

TypeError: self (=u(z)) must be a relational expression

What is the right way to write this assumption?

edit retag close merge delete

Sort by ยป oldest newest most voted

Hello, @ripple_carry! The easiest way I know of achieving that effect is to explicitly declare the imaginary part of the function to be zero. Just use the imag_part_func argument for function as follows:

var('z')

u = function('u',imag_part_func=0)(z)
v = function('v',imag_part_func=0)(z)

f = u + i * v

show(f.diff(z).conjugate().expand().simplify_full())


This outputs

diff(u(z), z) - I*diff(v(z), z)


Hope this helps!

more