login
A323186
a(0) = 0, a'(0) = 0, a''(0) = 1, a''(1) = -1, a(n) = a(n-1) + a'(n), a'(n) = a'(n-1) + a''(n), a''(n) = -a''(n-1) if a(n-2) = 0, or else a''(n-1).
2
0, -1, -1, 0, 2, 3, 3, 2, 0, -3, -5, -6, -6, -5, -3, 0, 4, 7, 9, 10, 10, 9, 7, 4, 0, -5, -9, -12, -14, -15, -15, -14, -12, -9, -5, 0, 6, 11, 15, 18, 20, 21, 21, 20, 18, 15, 11, 6, 0, -7, -13, -18, -22, -25, -27, -28, -28, -27, -25, -22, -18, -13, -7, 0, 8, 15, 21, 26, 30, 33, 35, 36, 36, 35, 33, 30, 26, 21, 15, 8, 0, -9, -17, -24, -30, -35, -39, -42, -44, -45, -45, -44, -42, -39, -35, -30, -24, -17, -9, 0
OFFSET
0,5
COMMENTS
This sequence might be called the "Bad Driver's Sequence" as it fully "accelerates" or "decelerates" when it changes side of its "speed limit".
LINKS
FORMULA
a'(n) = A053615(n)*(-1)^ceiling((sqrt(4n+1)-1)/2).
a''(n) = (-1)^ceiling(sqrt(n)).
a''(n) changes sign at A002522, a(n) = 0 at A005563.
a(n) has local extrema (with a'(n) = 0) at the oblong numbers A002378 with the value of A000217(n)*(-1)^n, the magnitude of which is the corresponding triangular number, as such |a(n)| <= n/2.
EXAMPLE
a''(0) = 1, a'(0) = 0, a(0) = 0.
a''(1) = -1, a'(1) = 0 - 1 = -1, a(1) = 0 - 1 = -1.
a(2-2) = a(0) = 0, so a''(2) = -a''(1) = 1, a'(2) = -1 + 1 = 0, a(2) = -1 + 0 = -1.
PROG
(Haskell)
a(0) = 0
a(1) = -1
a(2) = -1
a(n) = if a(n-2) == 0 then a(n-1) + a'(n-1) - a''(n-1) else a(n-1) + a'(n-1) + a''(n-1)
where a'(n) = a(n) - a(n-1)
a''(n) = a'(n) - a'(n-1)
(Perl)
my @a = (0, -1, -1);
for my $n (scalar(@a)..1000) {
if ($a[$n - 2] == 0) {
$a[$n] = $a[$n - 1] + &as($n - 1) - &ass($n - 1);
} else {
$a[$n] = $a[$n - 1] + &as($n - 1) + &ass($n - 1);
}
print "$n $a[$n]\n";
} # for n
sub as { my ($n) = @_; return $a[$n] - $a[$n - 1]; }
sub ass { my ($n) = @_; return &as($n) - &as($n - 1); }
# Georg Fischer, Feb 14 2019
CROSSREFS
KEYWORD
sign,look
AUTHOR
Thomas Anton, Jan 06 2019
EXTENSIONS
a(44) corrected [18, not -18] by Tom Duff, Feb 14 2019
STATUS
approved