Expression that alternates between 0 and 1?

For the discussion of math. Duh.

Moderators: gmalivuk, Moderators General, Prelates

Rippy
Posts: 2101
Joined: Sun Jul 22, 2007 11:27 pm UTC
Location: Ontario, Can o' Duh

Expression that alternates between 0 and 1?

We have to find a closed form equation for a sum in my algebra assignment. I found something that is so friggin' close: It is perfect except that you need to add 1 for odd values of n. The TA hinted that for one question you might have to split it into even and odd cases, and that's what I did, and that's how I'll hand it in since it's due tomorrow. But I'm still curious as to whether there's any way of making it work algebraically, sort of like how you can apply $(-1)^n$ to make a sequence alternate sign for example.

I can post the full question if anyone's curious and wants to have a go at it, it was kind of fun to work out although not too difficult (minus the half hour I spent trying to get it to work before I found out you were allowed to split up the cases...)

rat4000
r/ratsgonewild
Posts: 451
Joined: Mon Feb 09, 2009 7:51 pm UTC

Re: Expression that alternates between 0 and 1?

(-1)^n + n modulo 2?

It is basically what you did, true, but it doesn't involve splitting cases...

antonfire
Posts: 1772
Joined: Thu Apr 05, 2007 7:31 pm UTC

Re: Expression that alternates between 0 and 1?

You have an expression which alternates between -1 and 1. Find a function which takes -1 to 0 and 1 to 1.
Jerry Bona wrote:The Axiom of Choice is obviously true; the Well Ordering Principle is obviously false; and who can tell about Zorn's Lemma?

stephentyrone
Posts: 778
Joined: Mon Aug 11, 2008 10:58 pm UTC
Location: Palo Alto, CA

Re: Expression that alternates between 0 and 1?

antonfire wrote:You have an expression which alternates between -1 and 1. Find a function which takes -1 to 0 and 1 to 1.

Very much this. There's absolutely no need for splitting cases.
GENERATION -16 + 31i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

Rippy
Posts: 2101
Joined: Sun Jul 22, 2007 11:27 pm UTC
Location: Ontario, Can o' Duh

Re: Expression that alternates between 0 and 1?

That would be the Heaviside function, unless there's something similar that I'm unaware of. Heaviside works, but it has cases within it, so technically it's not all that different. Is there some other function I'm not thinking of?

Macbi
Posts: 941
Joined: Mon Apr 09, 2007 8:32 am UTC
Location: UKvia

Re: Expression that alternates between 0 and 1?

No, all you need is a function (any function at all!) such that f(-1)=0 and f(1)=1

There are several simple functions that do this.
Indigo is a lie.
Which idiot decided that websites can't go within 4cm of the edge of the screen?
There should be a null word, for the question "Is anybody there?" and to see if microphones are on.

stephentyrone
Posts: 778
Joined: Mon Aug 11, 2008 10:58 pm UTC
Location: Palo Alto, CA

Re: Expression that alternates between 0 and 1?

Hint: plot the points (-1,0) and (1,1). You're looking for a function that passes through both of them. [imath]f(x) = \frac14(x+1)^2[/imath] is one such function; can you think of a simpler one?
GENERATION -16 + 31i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

d0nk3y_k0n9
Posts: 97
Joined: Sun May 03, 2009 4:27 pm UTC

Re: Expression that alternates between 0 and 1?

I can think of a really, really simple way to change what you've got into what you want, but I'm not sure if you want us to just give you the answer. The hints people have posted above should lead you to it anyway, so I'm going to put what my answer would be into spoilers.

Spoiler:
$\frac{(-1)^n+1}{2}$

Macbi
Posts: 941
Joined: Mon Apr 09, 2007 8:32 am UTC
Location: UKvia

Re: Expression that alternates between 0 and 1?

Of course it might be nicer to use a continuous periodic function like sin(x)
Indigo is a lie.
Which idiot decided that websites can't go within 4cm of the edge of the screen?
There should be a null word, for the question "Is anybody there?" and to see if microphones are on.

mr-mitch
Posts: 477
Joined: Sun Jul 05, 2009 6:56 pm UTC

Re: Expression that alternates between 0 and 1?

Quite simple.

Spoiler:
$\frac{(-1)^n+1}{2}$is 0 for odd n and 1 for even n You could also take one and divide by -2 for the opposite odd/even n's...which is the same as n mod 2, or for the first one, (n+1) mod 2

Bobobo
Posts: 11
Joined: Sun Aug 31, 2008 2:37 am UTC
Location: Melbourne

Re: Expression that alternates between 0 and 1?

i'm curious, what was the question?

Rippy
Posts: 2101
Joined: Sun Jul 22, 2007 11:27 pm UTC
Location: Ontario, Can o' Duh

Re: Expression that alternates between 0 and 1?

mr-mitch wrote:Quite simple.

Spoiler:
$\frac{(-1)^n+1}{2}$is 0 for odd n and 1 for even n You could also take one and divide by -2 for the opposite odd/even n's...which is the same as n mod 2, or for the first one, (n+1) mod 2

This is was what I was trying to figure out, and what I'm guessing most people were trying to point me towards. Someone else had found it and I was quite frustrated to have not thought of it. I'm pretty sure it just overcomplicates the question, but hey, maybe someone can make it work.

Here's the question: it was a graded assignment so I didn't want to be too specific at the time:

Find a closed form formula for $\sum^n_{i=1}(−1)^i(2i − 1)^2$ for n ≥ 1

If anyone can find a single closed-form equation for that sum and prove its validity, I would be very interested to see it. It's pretty straightforward to prove for two equations (by showing the odd case produces the even for n+1, and vice-versa), which is what I settled for, but I'm sure it's possible with a single equation.

Macbi
Posts: 941
Joined: Mon Apr 09, 2007 8:32 am UTC
Location: UKvia

Re: Expression that alternates between 0 and 1?

Nicest I can get it:
Spoiler:
$\frac{(4n^2-1)(-1)^n+1}{2}$
or even:
$\frac{(4n^2-1)cos(\pi n)+1}{2}$
or,
$\frac{(2n+1)(2n-1)cos(\pi n)+1}{2}$
Indigo is a lie.
Which idiot decided that websites can't go within 4cm of the edge of the screen?
There should be a null word, for the question "Is anybody there?" and to see if microphones are on.

BlackSails
Posts: 5315
Joined: Thu Dec 20, 2007 5:48 am UTC

Re: Expression that alternates between 0 and 1?

Rippy wrote:
If anyone can find a single closed-form equation for that sum and prove its validity, I would be very interested to see it. It's pretty straightforward to prove for two equations (by showing the odd case produces the even for n+1, and vice-versa), which is what I settled for, but I'm sure it's possible with a single equation.