Ask Your Question
1

Real and imaginary part of an expression with assumptions on variables

asked 2023-09-20 17:45:17 +0100

stla gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-09-20 22:39:40 +0100

eric_g gravatar image

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)
edit flag offensive delete link more

Comments

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)
Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 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.

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2023-09-20 17:45:17 +0100

Seen: 245 times

Last updated: Sep 20 '23