Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
0

Binomial expansion

asked 2 years ago

Emmanuel Charpentier gravatar image

Let :

var("a, b, c, j", domain="integer")
assume(a>0, b>0, c>0)
ex=(a¨b)^c

I want to get the bionomial expansion of ex, i. e. sum(binomial(c, j)*a^j*b^(c-j), j, 0, c). I seem to rember that such a way exists in Sage, but for dear life I'm unable to remember it.

Can some kind soul come to the rescue of my aging neurons ?

Preview: (hide)

Comments

1

What is a¨b ?

tmonteil gravatar imagetmonteil ( 2 years ago )

a typo for a+b.

Sorry...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 2 years ago

dan_fulea gravatar image

The more "complicated" step of giving the compact expression for the sum 0kn(nk)akbnk is successfully delivered in sage.

sage: var('a,b,k,n')
(a, b, k, n)
sage: sum(binomial(n, k)*a^k*b^(n-k), k, 0, n)
(a + b)^n

But for the converse step, i do not see the reason to get the expansion (exactly in the form above, not with a,b replaced, using k as a running variable). I never saw this, i never felt the need for this in the given generality. Of course, for explicit, non-variable values of n we can ask for the expansion:

sage: ((a + b)^5).expand()
a^5 + 5*a^4*b + 10*a^3*b^2 + 10*a^2*b^3 + 5*a*b^4 + b^5

Usually, we are using computer algebra systems (CAS) for a special (mathematical) human purpose, not for implementing all possible operations. Humans have a kind of sense for the progress, and implement then operations that are supporting the progress, thus simplifying an expression, making it more compact, is a wanted operation. Expanding the sum (a+b)n is not a simple task, since the implementer has to do this only for special cases. (Is the given expression a power? Is the exponent n here, but maybe n!+2022n(n+1)/2 somewhere else, integer? Is the base, a+b here, but abc7+nbb elsewhere, a binomial? If yes, and this does not happen very often, provide a method expand_binomial maybe for the given expression.) Wanting the method is simple and natural, but implementing it...

Preview: (hide)
link

Comments

@dan_fulea :

But for the converse step, i do not see the reason to get the expansion...

In this question, the OP was baffled by the fact that the solution given by Sage's solve_diophantine iq riddled with terms of the form (a+b2)t, tN, yet all solutions were integers for a large range of t. The key to explain this is that the terms of the successive powers of b2 in the development are of alternating signs and cancel out. Therefore, I needed Sage to develop this expression.

I seem to remember to have seen this substitution "somewhere in Sage's documentation", but my aging neurons won't allow me to retrieve what I'm hunting...

Thanks for your answer. Close, but no cigar..

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2 years ago )

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2 years ago

Seen: 625 times

Last updated: May 06 '22