[sage-support] Re: How to replace variables in function?

2008-12-09 Thread John H Palmieri

Try this instead:

# just as you had before:
r=2*2*pi
Pole1=r*exp(I*2*pi/3)
Pole2=-r
Pole3=r*exp(-I*2*pi/3)
Ts=0.1
# one change here:
var('f')
z=exp(I*2*pi*Ts*f)
p=(2/Ts)*(z-1)/(z+1)
H = (p^3)/((p-Pole1)*(p-Pole2)*(p-Pole3))

Then H (or  show(H)) will print out a complicated expression in terms
of f, and

H.subs(f=3)

will plug in f=3.

H.subs(f=3).n(4)

will gives a decimal approximation to H.subs(f=3) to 4 bits of
precision.

H.subs(f=3).n(digits=12)

will give an approximation to 12 decimal digits of precision.


Or, as Tim Lahey hints, you could define a function:

HH(x) = (x^3)/((x-Pole1)*(x-Pole2)*(x-Pole3))

Then 'HH(p)' will return the same thing as 'H' does.


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: How to replace variables in function?

2008-12-09 Thread Sand Wraith

Thank you! Than you all so much!

It was so difficult to continue my research without it! And I am so
glad Sage project have real support :-)
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: How to replace variables in function?

2008-12-08 Thread bsdz

(Sorry if this reply appears twice - 1st one disappeared?)

This worked for me: -

H, p, Pole1, Pole2, Pole3, Ts, z, f = var(H p Pole1 Pole2 Pole3 Ts z
f)
p = (2/Ts)*(z-1)/(z+1)
z = exp(I*2*pi*Ts*f)
H = (p^3)/((p-Pole1)*(p-Pole2)*(p-Pole3))
show(H)

The only difference is that I have declared the variables in the first
line. Hope that helps.

On Dec 8, 5:58 pm, Sand Wraith [EMAIL PROTECTED] wrote:
 Hi all! Please help me to replace variables:

 I have this function:

 H(p)=(p^3)/((p-Pole1)*(p-Pole2)*(p-Pole3))

 where Pole1,Pole2,Pole3 - complex:

 r=2*2*pi
 Pole1=r*exp(I*2*pi/3)
 Pole2=-r
 Pole3=r*exp(-I*2*pi/3)
 Ts=0.1

 And I need to make a few replaces:

 need to replace p with (2/Ts)*(z-1)/(z+1), where z is a new
 variable, and then replace z with exp(I*2*pi*Ts*f). To have H(f)
 function at the end.

 I am trying to write:

 z=exp(I*2*pi*Ts*f)
 p=(2/Ts)*(z-1)/(z+1)
 H=(p^3)/((p-Pole1)*(p-Pole2)*(p-Pole3))

 and now if I want to look at H:
 H
 or
 show(H)
 I've got many errors...

 tail of long output:

 sage-display
 stdin:16:Incorrect syntax: Syntax error
 _tmp_ : (8000.0(
               ^
 sage-display(%o90)

 what is wrong with it?

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---