login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A319556 a(n) gives the alternating sum of length n, starting at n: n - (n+1) + (n+2) - ... + (-1)^(n+1) * (2n-1). 1
1, -1, 4, -2, 7, -3, 10, -4, 13, -5, 16, -6, 19, -7, 22, -8, 25, -9, 28, -10, 31, -11, 34, -12, 37, -13, 40, -14, 43, -15, 46, -16, 49, -17, 52, -18, 55, -19, 58, -20, 61, -21, 64, -22, 67, -23, 70, -24, 73, -25, 76, -26, 79, -27, 82, -28, 85, -29, 88, -30 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,3

COMMENTS

As can be observed from Bernard Schott's formula, and also proved using elementary methods of slope and angle determination, extending the graph of this sequence forms two lines (given by y = 1.5x - 0.5 and y = -0.5x) that intersect at (0.25, -0.125) in an angle of intersection of ~82.87 degrees. The angles of incidence of these lines off the horizontal axis are ~56.31 and ~-26.56 degrees.

If one wished to include negative input values, one could proceed, e.g., -3+4-5 (=-8) or -3+2-1 (=-2). If the former, then the sequence merely switches signs for negative inputs, graphically extending the previous lines to the left of the vertical. If the latter, two new lines emerge left of the vertical, both of slope 1/2. Increasing the run in this case "spreads apart" all y-intercepts.

LINKS

Mark Povich, Table of n, a(n) for n = 1..10000

Index entries for linear recurrences with constant coefficients, signature (0,2,0,-1).

FORMULA

From Bernard Schott, Aug 27 2019: (Start)

a(2*n-1) = 3*n-2 for n >= 1,

a(2*n) = - n for n >= 1.

(End)

a(n) = Sum_{k=n..2*n-1} (-1)^(n-k)*k.

From Colin Barker, Sep 07 2019: (Start)

G.f.: x*(1 - x + 2*x^2) / ((1 - x)^2*(1 + x)^2).

a(n) = 2*a(n-2) - a(n-4) for n>4.

a(n) = (-1 + (-1)^n + (2-4*(-1)^n)*n) / 4.

(End)

E.g.f.: (1/4)*exp(-x)*(1 + 4*x + exp(2*x)*(-1 + 2*x)). - Stefano Spezia, Sep 07 2019 after Colin Barker

EXAMPLE

If n=5, a(n)=7, since 5-6+7-8+9 = 7.

If n=6, a(n)=-3, since 6-7+8-9+10-11 = -3.

MATHEMATICA

LinearRecurrence[{0, 2, 0, -1}, {1, -1, 4, -2}, 60] (* Metin Sariyar, Sep 15 2019 *)

PROG

(Python)

def alt(k):

    return sum(k[::2])-sum(k[1::2])

def alt_run(n):

    m = []

    m.append(n)

    for i in range (1, n):

        m.append(m[0]+i)

    return alt(m)

t=[]

for i in range (100):

    t.append(alt_run(i))

print(t)

(PARI) a(n) = sum(k=n, 2*n-1, (-1)^(n-k)*k); \\ Michel Marcus, Aug 27 2019

(PARI) Vec(x*(1 - x + 2*x^2) / ((1 - x)^2*(1 + x)^2) + O(x^60)) \\ Colin Barker, Sep 07 2019

CROSSREFS

Cf. A123684.

Sequence in context: A126091 A026189 A026213 * A225126 A123684 A180076

Adjacent sequences:  A319553 A319554 A319555 * A319557 A319558 A319559

KEYWORD

sign,easy

AUTHOR

Mark Povich, Aug 27 2019

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 25 02:36 EDT 2021. Contains 345449 sequences. (Running on oeis4.)