Re: [sage-support] Power series expansion

2011-12-02 Thread Carl Eberhart
Hi Julie,
I'm new here, but if I understood your question, something like works to
give the power series expansion of a nice function f
about x=a

def taylor(f,a,n):
tay=f(a)
g = diff(f(x),x)
for i in range(1,n):
tay=tay+g(a)/factorial(i)*(x-a)^i
return tay

#now get the first 4 terms of the expansion of .248244^x about a=0
y=var('y')
taylor((.248244)^x,0,4)(x=y)

Then in order to get the coefficients you want, you'll need to multiply out
and collect like terms

Carl



On Fri, Dec 2, 2011 at 7:24 AM, Julie juliewilliams...@googlemail.comwrote:

 Hi all,

 I am attempting to obtain coefficients of a generating function to
 obtain probabilites, but in order to obtain the coefficients, I first
 need to expand a power series, which is necessary for my paricular
 function.
 Is there a simple way to expand such a series in sage e.g. 2^x?

 (For my exact problem, the generating function contains 2 variables (p
 and y), and when expanded up to terms where p=1 for example, I have
 the formula:
 (0.030*0.248244^y)y+0.05721*(0.248244^y)p +0.08838*(0.248244^y)

 Thus, before being able to extract the coefficients of p^0*y^0, p1,
 y1,p*y etc, I need to expand 0.248244^y as a power series - will the
 same programming also hold for this problem?)

 Many thanks,
 Julie

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Power series expansion

2011-12-02 Thread Carl Eberhart
Oops! I left out a line.  Sorry

def taylor(f,a,n):
tay=f(a)
g = diff(f(x),x)
for i in range(1,n):
tay=tay+g(a)/factorial(i)*(x-a)^i
g = diff(g(x),x)
return tay
y=var('y')
taylor((.324)^x,0,4)(x=y)

Carl

On Fri, Dec 2, 2011 at 7:24 AM, Julie juliewilliams...@googlemail.comwrote:

 Hi all,

 I am attempting to obtain coefficients of a generating function to
 obtain probabilites, but in order to obtain the coefficients, I first
 need to expand a power series, which is necessary for my paricular
 function.
 Is there a simple way to expand such a series in sage e.g. 2^x?

 (For my exact problem, the generating function contains 2 variables (p
 and y), and when expanded up to terms where p=1 for example, I have
 the formula:
 (0.030*0.248244^y)y+0.05721*(0.248244^y)p +0.08838*(0.248244^y)

 Thus, before being able to extract the coefficients of p^0*y^0, p1,
 y1,p*y etc, I need to expand 0.248244^y as a power series - will the
 same programming also hold for this problem?)

 Many thanks,
 Julie

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org