
#1
Mar1507, 11:47 PM

P: 213

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. 



#2
Mar1607, 12:00 AM

P: 1,076

What about
y=sin^{2}(x*pi/2) 



#3
Mar1607, 12:25 AM

P: 213

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




#4
Mar1607, 03:01 AM

Sci Advisor
HW Helper
P: 9,398

Odd and Even equation 



#5
Mar1607, 03:21 AM

P: 530

How about
mod(x,2) 



#6
Mar1607, 03:49 AM

P: 213

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. y_{k+1}=(3y_{k}+1)(sin^{2}(y_{k}pi/2))+(y_{k}/2)(cos^{2}(y_{k}pi/2)) 



#7
Mar1607, 03:55 AM

P: 530

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




#8
Mar1607, 03:57 AM

P: 213

I didn't know that.
Well, thanks then. Learned something new. But what are those kind of equations called? Edit: Is that parametric equations? 



#9
Mar1607, 03:58 AM

P: 530

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




#10
Mar1607, 03:59 AM

Sci Advisor
HW Helper
P: 9,398

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). 



#11
Mar1607, 04:05 AM

P: 213





#12
Mar1607, 10:17 AM

P: 530

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




#13
Mar1607, 10:59 AM

Sci Advisor
HW Helper
P: 9,398

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).




#14
Mar1607, 01:28 PM

P: 213

______________ 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. 



#15
Mar1607, 01:31 PM

Sci Advisor
HW Helper
P: 9,398

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.




#16
Mar1607, 02:49 PM

P: 213

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 y_{k}) 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. 1Intermediate loops inside any y interval 2Continuous increments towards positive infinity. 3Continuous 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 



#17
Mar1607, 02:54 PM

Sci Advisor
HW Helper
P: 9,398

That doesn't make sense unless you bother to define what an 'intermediate' loop is.




#18
Mar1607, 02:57 PM

P: 213

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 > ...... 


Register to reply 
Related Discussions  
Deriving the continuity equation from the Dirac equation (Relativistic Quantum)  Advanced Physics Homework  3  
[SOLVED] Lenses  ThinLens Equation and Magnification Equation  Introductory Physics Homework  2  
Why is Euler equation similar to the gradient of HamiltonJacobi equation?  General Physics  1  
Why is Euler equation similar to the gradient of HamiltonJacobi equation?  General Physics  1  
Laplace's Equation and Seperation of Multivariable Differential Equation  Introductory Physics Homework  2 