Easiest way to compute large set of numbers

28 Views Asked by At

4−12+36−108+324−...+236,196

What is the common trick to compute numbers with the same path ?

Here the path is have x-3x+3(3x)-.....

Thanks!

2

There are 2 best solutions below

0
On

So the number is

$4 - 3*4 + 3^2*4 - ...... + 3^10*4 = $

$4(1 - 3 + 3^2 - ...... + 3^{10})=$

$4(1 + (-3)^1 +(-3)^2 + ..... + (-3)^{10}) = $

$4\frac {1+ (-3)^{11}}{1 - (-3)}=$ (do you know that trick? [1])

$4\frac {1 - 3^{11}}{4} = 1 - 177147= -177146$

====

[1]$(1 + a + a^2 + ..... + a^n)(1-a)=$

$(1 + a + a^2 + ..... + a^n)-(a + a^2 + a^2 + ..... + a^{n+1})=$

$(1- a^{n+1})$ and therefore:

$ 1 + a + a^2 + ..... + a^n= \frac {1 - a^{n+1}}{1-a} $

And $r + ra + ra^2 + ..... + ra^n = r\frac {1 - a^{n+1}}{1-a}$

It's a very handy trick. It called a geometric series

1
On

This is a Geometric Series, i.e. a sum of a sequence of numbers where each number is obtained from the previous by multiplying by the same number each time. For example, the sum $1-2+4-8+\cdots$ is a Geometric Series since you get each number by multiplication by $-2$ whereas $1+2+4+8+24+72+\cdots$ is not Geometric since there is not a consistent number to get to the next number each time.

If you are summing a finite number of geometric terms, the sum is $$ a+ar+ar^2+\cdots= a \left( \dfrac{1-r^n}{1-r} \right), $$ where $a$ is the first number, $r$ is the number you multiply by, i.e. the common ratio, and $n$ is the number of terms. For example, $$ 1-3+9-27+81= 1 \cdot \left(\dfrac{1-(-3)^5}{1-(-3)} \right)= $$

If you use an infinite amount of terms, then the sum is $$ a+ar+ar^2+\cdots+ar^3+\cdots= \dfrac{a}{1-r}, $$ assuming that the number $r$ you multiply by has the property that $-1<r<1$, otherwise the sum will not converge. For example, $$ 3- \dfrac{3}{2} + \dfrac{3}{4} - \dfrac{3}{8} + \cdots = \dfrac{3}{1-(-1/2)}= \dfrac{3}{3/2}= 3. $$ For more on this, check out the Wiki page: Geometric Series