Message Boards Message Boards

0
|
1725 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Sum containing finite geometric sequence

Posted 1 year ago

How can I force Mathematica to simplify sum containing finite geometric sequence?

s=Sum[q^k,{k,0,20}]

(* s=1 + q + q^2 + q^3 + q^4 + q^5 + q^6 + q^7 + q^8 + q^9 + q^10 + q^11 + 
q^12 + q^13 + q^14 + q^15 + q^16 + q^17 + q^18 + q^19 + q^20 *)

Simplify[s, q != 1]

(* I get *)
(* 1 + q + q^2 + q^3 + q^4 + q^5 + q^6 + q^7 + q^8 + q^9 + q^10 + q^11 + 
    q^12 + q^13 + q^14 + q^15 + q^16 + q^17 + q^18 + q^19 + q^20 *)

(* I would like to get *)
(* (q^21 - 1)/(q - 1) *)
POSTED BY: S P
2 Replies

Another way:

Sum[q^k, {k, 0, n}] /. n -> 20
POSTED BY: Gianluca Gorni

Somewhat disappointing performance... If you already know the answer, you can do this:

Simplify[s (q - 1)]/(q - 1)
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract