This is making think the function is contradicting

  • Thread starter look416
  • Start date
  • Tags
    Function
In summary: The even integers, 0, 2, 4, 6, ... are mapped to 0, 1, 2, 3, ... and the odd integers, 1, 3, 5, 7, ... are mapped to 0, -1, -2, -3, ...In summary, the conversation discusses finding a function that is one-to-one and has a range of all integers, despite there being more integers in the set Z than in the set N. The suggested solution is to map odd positive numbers to negative integers and even positive numbers to positive integers. This function is both one-to-one and onto the set of integers.
  • #1
look416
87
0
This is making think the function is contradicting.
the question is asking me to find a function f : N → Z which is one-to-one and has range Z.
the problem is the number is integers in Z is bigger than the number of integers in N.

The only way i can think of is optional function, even that i also have no idea on solving it
 
Mathematics news on Phys.org
  • #2


Try a function which "jumps around". That is: one time a value will be a positive integer, the next time it will be negative.
 
  • #3


Hey look416.

Following micromasses suggestion, try thinking about f(N) = (-1)^N [N/2] where [N/2] returns the integer part of N/2.
 
  • #4


Thx Chiro, i see how the sequence goes ady. So, we are ignoring the floating point division but instead focusing on the integer division... i see
 
  • #5


Now,i got one more question, when n = 0, f[x] = 0, but when n = 1, f[x] = 0 too, this will make my function into a not one to one function ady
 
  • #6


chiro said:
Hey look416.

Following micromasses suggestion, try thinking about f(N) = (-1)^N [N/2] where [N/2] returns the integer part of N/2.

How about f(N) = (-1)^(N+1) [(N+1)/2]
 
  • #7


jing2178 said:
How about f(N) = (-1)^(N+1) [(N+1)/2]

That should work as well :)
 
  • #8


chiro said:
Hey look416.

Following micromasses suggestion, try thinking about f(N) = (-1)^N [N/2] where [N/2] returns the integer part of N/2.

look416 said:
Now,i got one more question, when n = 0, f[x] = 0, but when n = 1, f[x] = 0 too, this will make my function into a not one to one function ady

jing2178 said:
How about f(N) = (-1)^(N+1) [(N+1)/2]

chiro said:
That should work as well :)

Sorry Chiro I do not understand the 'as well' comment.

f(N) = (-1)^N [N/2] fails the 1 to 1 condition as f(0)=0 and f(1)=0;

Whereas for f(N) = (-1)^(N+1) [(N+1)/2]

f(0) = 0 f(1) = 1 f(2) = -1 f(3) = 2 f(4) = -2 f(5) = 3 f(6) = -3

f(7) = 4 f(8) = -4 etc
 
  • #9


jing2178 said:
Sorry Chiro I do not understand the 'as well' comment.

f(N) = (-1)^N [N/2] fails the 1 to 1 condition as f(0)=0 and f(1)=0;

Whereas for f(N) = (-1)^(N+1) [(N+1)/2]

f(0) = 0 f(1) = 1 f(2) = -1 f(3) = 2 f(4) = -2 f(5) = 3 f(6) = -3

f(7) = 4 f(8) = -4 etc

Before I answer I should ask whether the function is onto not onto.
 
  • #10


look416 said:
This is making think the function is contradicting.
the question is asking me to find a function f : N → Z which is one-to-one and has range Z.
the problem is the number is integers in Z is bigger than the number of integers in N.

The only way i can think of is optional function, even that i also have no idea on solving it

look416 set the range as Z so for me that means onto
 
  • #11


Rather than trying to give a specific formula, map odd positive numbers, of the form 2n+1, to -n and even positive numbers, of the form 2n, to n. That is both one to one and onto the set of integers.
 
  • #12


HallsofIvy said:
Rather than trying to give a specific formula, map odd positive numbers, of the form 2n+1, to -n and even positive numbers, of the form 2n, to n. That is both one to one and onto the set of integers.

I agree HallsofIvy. It is just that if a formula is tried and found not to work but is correctable then does it not behove us to correct it?
 
  • #13


HallsofIvy said:
Rather than trying to give a specific formula, map odd positive numbers, of the form 2n+1, to -n and even positive numbers, of the form 2n, to n. That is both one to one and onto the set of integers.

i need more clarification of this,
HallsofIvy, why we are mapping from 2n+1 to -n for odd numbers and 2n to n for even numbers?
 
  • #14


look416 said:
i need more clarification of this,
HallsofIvy, why we are mapping from 2n+1 to -n for odd numbers and 2n to n for even numbers?

Because it works. Did you try it?
Try writing it out for a few values of N.
 
  • #15


look416 said:
i need more clarification of this,
HallsofIvy, why we are mapping from 2n+1 to -n for odd numbers and 2n to n for even numbers?
You said you wanted a function that mapped positive integers to all integers. That's what this does.
 

FAQ: This is making think the function is contradicting

What does it mean for a function to be contradicting?

A contradicting function is one that produces outputs that are inconsistent or opposite from what is expected or desired. This can happen if there are errors in the function's logic or if the function is not designed to handle certain inputs.

How can I identify if a function is contradicting?

You can identify a contradicting function by testing it with different inputs and comparing the outputs to what is expected. If the outputs do not align with the expected results, then the function may be contradicting. Debugging tools and error messages can also help identify contradicting functions.

What are some common causes of contradicting functions?

Some common causes of contradicting functions include errors in the function's logic, incorrect use of conditional statements, and not accounting for all possible inputs. Poorly written code and lack of testing can also contribute to contradicting functions.

How can I fix a contradicting function?

The best way to fix a contradicting function is to carefully review and debug the code to identify any errors or missing logic. Proper testing with various inputs can also help identify and resolve contradicting behavior. Refactoring the code to improve its design and efficiency can also help prevent future contradictions.

Is it possible to completely avoid contradicting functions?

While it is not always possible to completely avoid contradicting functions, there are steps that can be taken to minimize the likelihood of them occurring. This includes writing clear and efficient code, thoroughly testing the function with various inputs, and continuously reviewing and improving the function's logic and design.

Similar threads

Replies
2
Views
998
Replies
6
Views
1K
Replies
13
Views
2K
Replies
5
Views
2K
Replies
1
Views
615
Replies
4
Views
2K
Back
Top