Expansion of binomials with Rational coeff

47 views
Skip to first unread message

Sachin Joglekar

unread,
Oct 7, 2012, 7:53:25 PM10/7/12
to sy...@googlegroups.com
In the special case where, in the expression (x+y)**n , n is non-integer Rational, shouldn't the expansion come out to be a series of the form

y**n+n*x*y**n-1+0.5*n*(n-1)*(x**2)*(y**n-2)+...+O(x**6) ?

Maybe this shouldn't be the default return for expand, but it would be nice to have the option of getting that particular binomial series, especially if value of n is known.

Something like (x+y+z)**n could be written by substituting (y+z) for y in the above expansion  (Thats how WolframAlpha shows it) or we could use recursion to expand each term of the form (y+z)**(n-r)

Sachin Joglekar

unread,
Oct 7, 2012, 9:26:50 PM10/7/12
to sy...@googlegroups.com
Just finished coding a method (named it 'expansion') to giv the above desired result. Example of input-output ->

>>> expansion((x+y)**2)
x**2 + 2*x*y + y**2
>>> expansion((3*a+2*b)**2)
9*a**2 + 12*a*b + 4*b**2
>>> expansion((x+y)**0.2)
x**0.2 + 0.2*x**-0.8*y - 0.08*x**-1.8*y**2 + 0.048*x**-2.8*y**3 - 0.0336*x**-3.8*y**4 + 0.025536*x**-4.8*y**5 + O(y**6)
>>> expansion((3*x+y+z+2)**3.4)
(3*x + z + 2)**3.4 + 3.4*y*(3*x + z + 2)**2.4 + 4.08*y**2*(3*x + z + 2)**1.4 + 1.904*y**3*(3*x + z + 2)**0.4 + 0.1904*y**4*(3*x + z + 2)**-0.6 - 0.022848*y**5*(3*x + z + 2)**-1.6 + O(y**6)

Ondřej Čertík

unread,
Oct 7, 2012, 11:53:48 PM10/7/12
to sy...@googlegroups.com
I think the only other way is to use series(). Would you mind sending
this as a github pull request?

Ondrej

Christophe BAL

unread,
Oct 8, 2012, 1:47:20 AM10/8/12
to sy...@googlegroups.com
Hello,
expansion((x+y)**0.2) should raise one error.

Christophe

Sachin Joglekar

unread,
Oct 8, 2012, 5:05:36 AM10/8/12
to sy...@googlegroups.com

I will send the request shortly. Even I used the series function, but it had to be processed to accomodate the presence of more than one variables in the expression.



Sachin Joglekar

unread,
Oct 8, 2012, 5:07:01 AM10/8/12
to sy...@googlegroups.com
The only question I have is how should I accomodate this functionality? Should I modify the expand() function or write this as a separate function?




Sachin Joglekar

unread,
Oct 8, 2012, 5:09:32 AM10/8/12
to sy...@googlegroups.com
@Christophe BAL ..Why would (x+y)**0.2 raise an error? I guess the binomial expansion of it would be an infinite series

Aaron Meurer

unread,
Oct 8, 2012, 10:46:34 AM10/8/12
to sy...@googlegroups.com
I'd put it as a separate function, or at least as a non default hint to expand. And if it goes in expand, it should give the whole summation. If it's just a series (with an O term) it should go in series somewhere. 

Aaron Meurer

On Oct 8, 2012, at 3:07 AM, Sachin Joglekar <srjogl...@gmail.com> wrote:

The only question I have is how should I accomodate this functionality? Should I modify the expand() function or write this as a separate function?




--
You received this message because you are subscribed to the Google Groups "sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.

Sachin Joglekar

unread,
Oct 8, 2012, 11:08:17 AM10/8/12
to sy...@googlegroups.com

So we could just add a function say like 'binomial_series' in the series module?

Sachin Joglekar

unread,
Oct 8, 2012, 12:31:52 PM10/8/12
to sy...@googlegroups.com
And what is the best way, if any, to express the summation of an infinite series? That would be a nice way to represent the entire expression.

Aaron Meurer

unread,
Oct 8, 2012, 12:34:22 PM10/8/12
to sy...@googlegroups.com
Just use Sum(), and whatever combinatorial functions are necessary. We should have all the important ones. For the summation variable, use Dummy so that you know it won't clash with a symbol name used by the user. 

Aaron Meurer

On Oct 8, 2012, at 10:31 AM, Sachin Joglekar <srjogl...@gmail.com> wrote:

And what is the best way, if any, to express the summation of an infinite series? That would be a nice way to represent the entire expression.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/lEb3wN3EDeoJ.
Reply all
Reply to author
Forward
0 new messages