Ask Your Question
0

Additional conditions for expression

asked 2011-03-19 08:16:30 -0500

avi9526 gravatar image

updated 2011-05-12 09:28:57 -0500

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 ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2011-03-19 10:00:50 -0500

benjaminfjones gravatar image

updated 2011-03-19 10:07:00 -0500

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

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: 2011-03-19 08:16:30 -0500

Seen: 200 times

Last updated: Mar 19 '11