# Real and imaginary part of an expression with assumptions on variables

Hello,

I have this expression:

Exp[-(x+I*y)*sinh(t/(1-t)) - nu * t/(1-t)] * 1/(1-t)


All variables are real except nu which is a complex number. I want the real part and the imaginary part of this expression. I tried with Wolfram Alpha and either it assumes all variables are complex, or, of I specify some Assumptions, it does not return the result. Is it possible with Sage ? I'm very new to Sage. I'm new to GIAC too and I didn't found how to force a variable to be real.

edit retag close merge delete

Sort by ยป oldest newest most voted

In Sage, you can specify the domains of the variables when you declare them. Your example becomes then

sage: x, y, t = var('x y t', domain='real')
sage: nu = var('nu', domain='complex')
sage: assumptions()
[x is real, y is real, t is real, nu is complex]
sage: s = exp(-(x+I*y)*sinh(t/(1-t)) - nu * t/(1-t)) * 1/(1-t)
sage: s.real_part()
-cos(-y*sinh(-t/(t - 1)) + t*imag_part(nu)/(t - 1))*e^(-x*sinh(-t/(t - 1)) + t*real_part(nu)/(t - 1))/(t - 1)
sage: s.imag_part()
-e^(-x*sinh(-t/(t - 1)) + t*real_part(nu)/(t - 1))*sin(-y*sinh(-t/(t - 1)) + t*imag_part(nu)/(t - 1))/(t - 1)

more

You can also temporarily add assumptions to the current global ones ; see assuming?. In your case :

sage: x, y, t, nu = var('x y t nu') # No assumptions
sage: s = exp(-(x+I*y)*sinh(t/(1-t)) - nu * t/(1-t)) * 1/(1-t)
sage: s.real_part().simplify() # Without assumptions
-t*cos(y*sinh(t^2/(t^2 - 2*t + 1) - t/(t^2 - 2*t + 1)))*e^(nu*t^2/(t^2 - 2*t + 1) + x*sinh(t^2/(t^2 - 2*t + 1) - t/(t^2 - 2*t + 1)) - nu*t/(t^2 - 2*t + 1))/(t^2 - 2*t + 1) + cos(y*sinh(t^2/(t^2 - 2*t + 1) - t/(t^2 - 2*t + 1)))*e^(nu*t^2/(t^2 - 2*t + 1) + x*sinh(t^2/(t^2 - 2*t + 1) - t/(t^2 - 2*t + 1)) - nu*t/(t^2 - 2*t + 1))/(t^2 ...
(more)
( 2023-09-21 07:41:58 +0100 )edit

Thanks. I found how to do with GIAC. It assumes all variables are real, and you can use i for the imaginary unit. So it suffices to write nu = a + i*b and to apply the function re and im.

( 2023-09-25 01:40:40 +0100 )edit