Odd and Even equation

• cshum00

cshum00

I have been wondering were to put this question but since it is related to algebra, i think i'll post it here.

I was playing with numbers and suddenly i came up with the idea of wanting to make a equation f(x) where all x odd number domain will result of range 1, and all even number domain will result of range 0.

so:
if x = even, f(x) = 0
if x = odd, f(x) = 1

x can only be whole integers {...,-2,-1,0,1,2...}
y can only be 0 or 1

I want only one equation that give me such result. Please lend me a hand. I have been cracking my head all day and i always get it wrong.

Thanks.

Answers and Replies

What about
y=sin2(x*pi/2)

Great! Thanks! That is one way to do it. I wonder if you can make it into step functions? Pretty plesase

I want only one equation that give me such result.

Why do you want that?

How about

mod(x,2)

Why do you want that?
Well, there was this problem in my c++ class that include odd and even numbers. The problem begins that you pick a number and if the number is
-Odd then 3x+1
-Even then x/2

So suppose that i pick 5, then since it is odd it will start:
5 -> 16 -> 8 -> 4 -> 2 -> 1 -> 4 -> 2 -> ...
When the number becomes odd, the odd condition is applied. When the number becomes even, the even condition is applied. However, there is also a loop in there. As you can see that from 1 it goes back to 4. The original problem was how to make a loop that doesn't go forever and it was by adding the condition that when x = 1 stop or while x is different to 1 continue to loop.

However, the problem was extended to that supposing you pick a very large number. And because of the magnitude of the number, there could be a intermediate loop before reaching x = 1 which makes the program loop for ever even if you have the x = 1 condition. Is there any way to find that there is a intermediate loop inside and stop it? Then the professor explain that it is a little game that mathematicians like to play with and they don't have an answer. But i decided to play a bit as well.

I begun to play with real equations and real numbers and i got as far as to be able to write a difference equation which i learned not very long ago and it serves some of my basic purposes to be able to determine the intermediate loop.
yk+1=(3yk+1)(sin2(ykpi/2))+(yk/2)(cos2(ykpi/2))

How about
mod(x,2)
That is for programing, right? To be specific, Matlab right? But I am actually trying to get is an equation.

Last edited:
mod(x,2) is a function like any other function. It's perfectly well known by mathematicians.

I didn't know that.

Well, thanks then. Learned something new.

But what are those kind of equations called?

Edit: Is that parametric equations?

I don't think there's any way to tell in advance if this loop terminates. There may be a proof to that extent.

Then the professor explain that it is a little game that mathematicians like to play with and they don't have an answer.

It is a very famous and old problem (the 3n+1 problem). It is not known if the sequence terminates in 1 or not for all starting values. In fact Conway (I think) has shown there are variations where it is an undecidable problem.

Equations like sin are going to be useless for C++ (only if you have a symbolic computer library will you be OK to use pi - remember to evaluate something like sin the computer will only use approximations, and even then you have to load math.h in C, say).

I seem to remember that

if(x % 2 ==1) then
(do something on odd numbers
else
do something else on even numbers (though I don't promise to have my precedence of operators correct)

would do. Every computer language has a modulo function, and I think it is % in C, C++, python, perl et al.

This is modular arithmetic (aka clock arithmetic).

Last edited:
I don't think there's any way to tell in advance if this loop terminates. There may be a proof to that extent.
True, that is why it will require change to the code but i want to check it analytically first.Well it doesn't hurt to play around with it. After all i do learn new things too!

It is a very famous and old problem (the 3n+1 problem). It is not known if the sequence terminates in 1 or not for all starting values. In fact Conway (I think) has shown there are variations where it is an undecidable problem.

Equations like sin are going to be useless for C++ (only if you have a symbolic computer library will you be OK to use pi - remember to evaluate something like sin the computer will only use approximations).

I seem to remember that

if(x % 2 ==1) then

else

would do. Every computer language has a modulo function, and I think it is % in C, C++, python, perl et al.

This is modular arithmetic (aka clock arithmetic).
Yeah, i heard it was famous but since it is new for me i would like to play it a bit longer until i get bored about it. We already did the past of the modulus and all but i still want to try to see if i can find the loops and if i can i learn even more! It is true that programing languages make approximations that is why i am doing them by hand as well. That is why i wrote the difference equation.

Last edited:
Well, remember us if you succeed and get the Fields medal for math.

It is always difficult to decide if one should encourage work like this, or offer strong cautions. I think I would have to edge towards the latter: this problem is very old, very well studied, and no solution has been found. Similar examples are known to be undecidable. It is not something you should start with - I'm sure there are better things to learn from that you can actually make progress with (even if it is already known to someone else).

Well, remember us if you succeed and get the Fields medal for math.
I don't think that i am that good yet but if i get it by chance, it would be based and thanks to all the pieces of information that you guys provided me.

______________
matt grime. I understand what you mean. If it is something that i mathematicians haven't been able to solve, there is a very little change that i would - especially with my limited knowledge in mathematics. But who, knows by the smallest change there still a possibility.

Or even if i am not able to solve it at all, i would be able to learn new things on the way. Things that i never thought there were and things i never thought i could use it that way.

I mean with the helps of you guys i was able to get the a function where any odd and even integer number will give me only 0 or 1. I learned a new notation (which i haven't been the name of it yet). I even applied difference equations which i hated so much a few days ago because it is too much trouble to get the results analytically.

Besides i really feels encouraging and challenging to do things that sot everyone can solve.

Last edited:
Doing something hard (impossible even) can be useful, but just as long as you're prepared to accept in advance that, whatever else you may gain, progress towards a solution is unlikely, so don't be disappointed.

Well, i have been able to make so progress. I am using MATLAB to graph the difference equations and i have been able to identify a few patterns.

In the case of:
Odd then 3x +1
Even then x/2

-Intermediate loops most likely happen when x is close to 0
-in positive numbers we know that intermediate loop will occur once x reach 1. But in negative integers there are more than one possible -x close to 0 which would lead to intermediate loops (try different -yk)
-Most integer numbers inputed (regardless of being positive or negative) would most likely go close to 0 as the process is carried on.

Without the graph, there are a few more patterns you can see by analyzing the odd and even conditions.
-If odd, then (3x+1) will always transform x to even.
-If even, then (x/2) might or might not transform x to odd.
-If negative odd, then (3x+1) will lead first father away from 0 then +1 unit closer to 0.
-If positive odd, then (3x+1) will always lead father away from 0.
-If positive or negative even, then (x/2) will lead closer to 0.

Big numbers can possibly have more than one whole division by 2 which will most likely lead the numbers towards 0.
Any odd number will always convert it to even, therefore, most likely be reduced again.

There are 3 cases where there will be loops which leads to no end.
1-Intermediate loops inside any y interval
2-Continuous increments towards positive infinity.
3-Continuous decrements towards negative infinity.

I found case number 2 and 3 by graphing large positive or negative numbers in matlab. I am not sure if it was overflow or if it is going towards large infinity then goes back close to 0 (unless i can do it analytically).

Here is my MATLAB script file so that you can analyze the problem as well if you have the software.

Edit: Intermediate loops is my short way to call the loops that repeat the same values

Attachments

• cycle.m
650 bytes · Views: 351
Last edited:
That doesn't make sense unless you bother to define what an 'intermediate' loop is.

I am sorry about it. I mean it like it loops with always repeat the same values.

For example:

1 -> 4 -> 2 -> 1 -> 4 -> 2 -> 1 -> 4 -> 2 -> 1 -> ...

There are no known non-trivial (i.e. without a 1 in them) intermediate loops. That's the whole point of the problem.

You have found out what the proper statement of the 'hard' conjecture is, right?

Given the operation above, it is conjectured that every possible starting (positive at least) integer reaches 1 eventually. This is a *very hard* conjecture, and has been extensively investigated, and verified for many many starting values. There are similar problems which are known to be undecidable (do you know what the formal definition of undecidable is?).

Last edited:
It is somehow related with randomness. I know that 1 as part of the intermediate loop because i picked the number but if it where random, there is not a general rule that can make it work the way it does, right? Is that what you mean by undecidable?

You can always tell me your definition of undecidable so that i make sure i understand.

True that 1 won't define everything but this is a clue for the many possible patterns in the infinite set of numbers. Besides, even though the problem is undecidable, this one is bound to a few restrictions which is odd, even and the two equations (3x+1) and (x/2).

By detailing out every possible pattern is one way to begin a research. Unless you are telling me that i should tackle it without any aims or i should be a genius that is able to see through it instantly.

Edit: Although the statements are hard conjectures they are the ones that i can use at the moment so that i can progress. I am putting them in here in case anyone is interested in doing the problem too.

Anything else, If the statements are wrong then tell me so that i can correct it.

Last edited:
It is somehow related with randomness. I know that 1 as part of the intermediate loop because i picked the number but if it where random, there is not a general rule that can make it work the way it does, right? Is that what you mean by undecidable?

no. google it. approximately it means 'a proposition cannot be deduced from the axioms of arithmetic, and nor can its negation'

True that 1 won't define everything

I have no idea what you mean by that.

but this is a clue for the many possible patterns in the infinite set of numbers. Besides, even though the problem is undecidable,

I didn't say that it (the 3n+1 conjecture) was undecidable, I said Conway (I think) found similar iterations that were undecidable. And bear in mind what 'undecidable' really means.

By detailing out every possible pattern is one way to begin a research.

It is impossible to write out 'every' possible series of iterations since there are infinitely many of them.

Unless you are telling me that i should tackle it without any aims or i should be a genius that is able to see through it instantly.

you should at least decide what it is you're trying to do - i presumed it was to answer the 3n+1 conjecture. Then do some examples to give an idea of what is going on as necessary. Proofs tend not to be done by example though. (Though some may be reduced to checking finitely many cases).

I know that i am doing proof by exhaustion which is not a smart way to do so because it will take me a infinite time to be able to deal with the infinite set of numbers. But as i said it is the beginning.

Rather than shutting me down, why don't you share what you know about it since you seem to know, so that it helps.

I feel like i am being in a court defending my rights to start a research. If you say that there is no answer then prove it. Not all the problems are solved as they come, mathematicians always tackled their problem because there wasn't a known solution by that time.

If you are telling me that it is a waste of time, the time i have i am the one to decide what to do with it. You might not be shutting me down intentionally but that is how it looks like if you don't believe me re-read all your previous posts.

I googled the word 'undecidable' and i wrote what i understood, that is why i asked you to explain it to me in case i am wrong. Or is it that my interpretation is not clear or i am using a different mentality since i am applying to the problem.

Edit: from wikipedia:
" * A decision problem is called (recursively) undecidable if no algorithm can decide it, such as for Turing's halting problem; see also under Decidable.
* "Undecidable" is sometimes used as a synonym of "independent", where a formula in mathematical logic is independent of a logical theory if neither that formula nor its negation can be proved within the theory."
I can't prove a theory with values or that there is no rule that can decide the values that i am assigning to it. But why is there such term? Isn't like i said that the numbers in reality are random and not assigned by me so that it has to do with randomness.

I have no idea what you mean by that.
You said that 1 is 'non-trivial' which that is why i said that it is true that 1 doesn't decide everything but it is one clue that i have.

Last edited:
Rather than shutting me down, why don't you share what you know about it since you seem to know, so that it helps.

I am not shutting you down, but as this thread has progressed, it has become clear that you are not familiar with the 3n+1 conjecture. The conjecture has turned out to be satsified for every starting value that people have tried (and thus it is unlikely that you will ever find any starting value that does anything other than eventually reach 1 and enter the trivial loop).

I feel like i am being in a court defending my rights to start a research. If you say that there is no answer then prove it.

It is a conjecture that it alway hits 1. No one has been able to prove it or disprove it, but many have spent years trying. I am trying to make you aware of that.

If you are telling me that it is a waste of time, the time i have i am the one to decide what to do with it. You might not be shutting me down intentionally but that is how it looks like if you don't believe me re-read all your previous posts.

again, I am not telling you not to do this. If you want, go ahead. My belief is that you would learn more if you investigated other things. Possibly including things that others have not thought of. As it is all you seem to be doing is just iterating things and either hitting 1 or going beyond the capability of your computer to do integer arithmetic. This is precisely what you could have predicted without doing any work by meta-reasoning.

You are completely free to spend as much time on this as you wish just iterating things. However, you should be aware of what has preceded you.

Edit: from wikipedia:
" * A decision problem is called (recursively) undecidable if no algorithm can decide it, such as for Turing's halting problem; see also under Decidable.
* "Undecidable" is sometimes used as a synonym of "independent", where a formula in mathematical logic is independent of a logical theory if neither that formula nor its negation can be proved within the theory."
I can't prove a theory with values or that there is no rule that can decide the values that i am assigning to it. But why is there such term? Isn't like i said that the numbers in reality are random and not assigned by me so that it has to do with randomness.

this has nothing to do with randomness. If you attempt to prove a problem in a model that is undecidable you will never succeed. Nor can you succeed in showing its negation. If tou could show that the 3n+1 conjecture is undecidable that would be important.

You said that 1 is 'non-trivial' which that is why i said that it is true that 1 doesn't decide everything but it is one clue that i have.

I said that non-trivial intermediate loops should be those that do not contain 1 in them. The existence, or non-existence of them, is what the conjecture is about.

Last edited:
I am not shutting you down, but as this thread has progressed, it has become clear that you are not familiar with the 3n+1 conjecture. The conjecture has turned out to be satsified for every starting value that people have tried (and thus it is unlikely that you will ever find any starting value that does anything other than eventually reach 1 and enter the trivial loop).
I already explained some time ago that it is new to me and i wanted to play with it until i get bored about it. As i said then why don't you tell me what you know so that i don't have to make redundant or meaningless search and so that i can progress faster and so that i know when to give up.

It is a conjecture that it alway hits 1. No one has been able to prove it or disprove it, but many have spent years trying. I am trying to make you aware o that.
Well that's good thing to know that it always hist 1 but then check it with negative numbers then you will see that it never hit 1.

again, I am not telling you not to do this. If you want, go ahead. My belief is that you would learn more if you investigated other things. Possibly including things that others have not thought of. As it is all you seem to be doing is just iterating things and either hitting 1 or going beyond the capability of your computer to do integer arithmetic. This is precisely what you could have predicted without doing any work by meta-reasoning.
I am thankful for your concerns but once in a while everyone have a hobby. Some watch tv others read books, i am just making a research and learning new things on the way.

this has nothing to do with randomness. If you attempt to prove a problem in a model that is undecidable you will never succeed. Nor can you succeed in showing its negation. If tou could show that the 3n+1 conjecture is undecidable that would be important.
Ok, rather that just telling me that it is wrong, why don't you explain the word to me with simple words and examples so that i can understand it better? It is not that i didn't ask you to explain it.

I said that non-trivial intermediate loops should be those that do not contain 1 in them. The existence, or non-existence of them, is what the conjecture is about.
Well, then negative numbers would be example of it. And from wikipedia: "n mathematics, a conjecture is a mathematical statement which appears likely to be true, but has not been formally proven to be true under the rules of mathematical logic." So like you said, 1 is likely to be true but since it is a value from the infinite sets. I can't prove with with 1 but like i said that your statement of it being trivial is 'True'. I didn't deny it.

Last edited:
The 3n+1 conjecture is about strictly *positive* integers - the (non-zero, just in case) natural numbers. One of the first things you do in research is search for what has been done.

There is plenty of writing out there about this conjecture, related conjectures, and undecidability. All written by experts, and my field does not overlap any of the areas involved. You're better off with them.

I'm not sure what more I can do other than say 'undecidability is not about randomness'. It is sort of like saying 'the colour green has nothing to do with the smell of bread'. I don't know that I have any simple examples.

Last edited:
The 3n+1 conjecture is about strictly *positive* integers - the natural numbers. One of the first things you do in research is search for what has been done.
Right then it means that my research haven't been pointless at all because i learned about how the conjecture might works in negative numbers.

The conjecture isn't about negative numbers...

It is not but it does not harm to play with negative numbers too. I might learn some patterns form the negative numbers which can or cannot be applied to positive numbers. And so i might learn why it does and why it does not.

Last edited:
Thanks for the info. :rofl:

Last edited: