First time here? Check out the FAQ!

Ask Your Question
0

Additional conditions for expression

asked 13 years ago

avi9526 gravatar image

updated 13 years ago

Kelvin Li gravatar image

Hi (sorry for bad eng.), i have next code

reset()
var('K1, T1, T2')
var('p')
# Transient function W(p)
W = K1 * p / ((T1 * p - 1) * (T2 * p - 1))
# Amplitude-phase-frequency characteristic W(jw)
Wa(omega) = W(p = I * omega)

Re(omega) = Wa(omega).real()
Im(omega) = Wa(omega).imag()

print(Re)

but last string gives loooooong result, because sagemath don't knows that K1, T1, T2 and omega are real, how to "tell" that to sagemath ?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 13 years ago

benjaminfjones gravatar image

updated 13 years ago

Try using assume (type assume? at the console or look through the Sage documentation):

sage: var('K1, T1, T2, p, omega')
(K1, T1, T2, p, omega)
sage: assume(K1, 'real')
sage: assume(T1, 'real')
sage: assume(T2, 'real')

You can also try simplifying your expression, even without the assumptions on K1, T1, and T2:

sage: W = K1 * p / ((T1 * p - 1) * (T2 * p - 1))
sage: Wa = W(p = I * omega)
sage: Re = Wa.real_part().full_simplify()
sage: Im = Wa.imag_part().full_simplify()
sage: 
sage: print(Re)
-(K1*T1*omega^2 + K1*T2*omega^2)/(T1^2*omega^2 + 
(T1^2*omega^4 + omega^2)*T2^2 + 1)
Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 13 years ago

Seen: 525 times

Last updated: Mar 19 '11