Checking weather any positive number is zero or not

In summary, the conversation is about trying to find a linear function f such that f(0)=0 and f(x)=1 for any positive integer x. The first proposed function, (2*x+1)/2 - (2*x-1)/2, was shown to not work. The second proposed function, ((2*x+3) % 2*(x-1)+3)/2, was also deemed to not fulfill the requirements because it is not linear. It was then suggested that a continuous function does not exist for this situation due to the IVT. However, it is possible to construct a function for integers, such as f(n) = [n/(n+1)], where [] represents the ceiling function.
  • #1
Lslander
2
0
I would like to have a function f such that f(0) = 0 and f(x) = 1 for any x>0. I can compute f in the following way:

f(x) = (2*x+1)/2 - (2*x-1)/2 . Here the division is integer division. But if x=0, here we divide (2*0-1)/2 or -1/2, which is a problem. Because we do not have any number -1 here.

We can also compute f(x) as follows
f(x) = ((2*x+3) % 2*(x-1)+3)/2 . Here % is remainder. This is also a problem because we are doing something like x%y which is nonlinear. To be clear x%2 is allowed, but x%y is not allowed.

So, can anyone help me constructing such a function which is linear and over positive integer and all operation will be integer operation? Or can anyone tell me that it is not possible to construct f with such restriction?

I really appreciate any help.
NB: f simply checks weather any positive number is zero or not and return 0 if 0 ;else return -1.
Thanks a lot...
 
Physics news on Phys.org
  • #2
"So, can anyone help me constructing such a function which is linear"

The function you are describing is non-linear by definition. So no, there is no linear function that can give the output:

f(0) = 0 and f(x) = 1 for any x>0


There is a piecewise linear function:

f(x) = { 0 if x=0
1 otherwise



But someone who knows math better than me may demonstrate this wrong...
 
  • #3
Lslander said:
I would like to have a function f such that f(0) = 0 and f(x) = 1 for any x>0. I can compute f in the following way:

For all integers greater than 0 or for all real numbers greater than 0?

If you want it for all real numbers greater than 0, you could use the piecewise function the previous poster suggested. If you weren't looking for a piecewise function, a continuous function does not exist. By the IVT, it's impossible to have a continuous function with this property.

With integers, it's possible.

Lslander said:
f(x) = (2*x+1)/2 - (2*x-1)/2 . Here the division is integer division. But if x=0, here we divide (2*0-1)/2 or -1/2, which is a problem. Because we do not have any number -1 here.

This example doesn't work. f(x) = (2*x+1)/2 - (2*x-1)/2 = x + (1/2) - x - (1/2) = 0, so really, this just says that f(x) = 0.

Lslander said:
We can also compute f(x) as follows
f(x) = ((2*x+3) % 2*(x-1)+3)/2 . Here % is remainder. This is also a problem because we are doing something like x%y which is nonlinear. To be clear x%2 is allowed, but x%y is not allowed.

I'm not sure what your definition of remainder is here.

Lslander said:
So, can anyone help me constructing such a function which is linear and over positive integer and all operation will be integer operation? Or can anyone tell me that it is not possible to construct f with such restriction?

Why not f(n) = [n/(n+1)], where [] is the ceiling function?
 
  • #4
gb7nash said:
For all integers greater than 0 or for all real numbers greater than 0?

If you want it for all real numbers greater than 0, you could use the piecewise function the previous poster suggested. If you weren't looking for a piecewise function, a continuous function does not exist. By the IVT, it's impossible to have a continuous function with this property.

With integers, it's possible.



This example doesn't work. f(x) = (2*x+1)/2 - (2*x-1)/2 = x + (1/2) - x - (1/2) = 0, so really, this just says that f(x) = 0.



I'm not sure what your definition of remainder is here.



Why not f(n) = [n/(n+1)], where [] is the ceiling function?
Dear gb7nash

Thanks for your reply.

"For all integers greater than 0 or for all real numbers greater than 0?"
I am considering natural numbers including 0.

"This example doesn't work. f(x) = (2*x+1)/2 - (2*x-1)/2 = x + (1/2) - x - (1/2) = 0, so really, this just says that f(x) = 0.
"
f(x) = (2*x+1)/2 - (2*x-1)/2 works because you have to consider (2*x-1) as a whole number. you should not simplify it. look when x=2, f(2)= (2*2+1)/2 - (2*2-1)/2 = 5/2-3/2= 2-1=1.

"I'm not sure what your definition of remainder is here."

c=a%b , d= a/b => a=d*b +c

"Why not f(n) = [n/(n+1)], where [] is the ceiling function?"

Since I am considering only positive integer number including 0, probably i cannot represent ceiling.

Thanks...
 
  • #5
f(x) = x^0 works but I don't know if that's quite what you're looking for.
 
  • #6
gb7nash said:
Why not f(n) = [n/(n+1)], where [] is the ceiling function?

Isn't the ceiling function notation ⌈x⌉ rather than the whole [x]
 
  • #7
dimension10 said:
Isn't the ceiling function notation ⌈x⌉ rather than the whole [x]

Yes, but I can't find ⌈⌉ on the keyboard. :tongue:
 

1. What is the purpose of checking if a positive number is zero or not?

The purpose of checking if a positive number is zero or not is to determine if the number is equal to zero or not. This can be useful in various mathematical and statistical calculations, as well as in programming and data analysis.

2. How do you check if a positive number is zero or not?

To check if a positive number is zero or not, you can use a simple comparison operation. For example, in most programming languages, you can use the "equal to" (==) operator to check if a number is equal to zero or not. If the number is equal to zero, the result will be true, and if it is not equal to zero, the result will be false.

3. Can a positive number ever be equal to zero?

No, a positive number can never be equal to zero. This is because a positive number, by definition, is any number that is greater than zero. Therefore, a positive number can never be equal to zero.

4. Why is it important to check if a positive number is equal to zero?

It is important to check if a positive number is equal to zero because it can help avoid errors and provide accurate results in mathematical and statistical calculations. It can also help in debugging and troubleshooting code in programming.

5. Are there any other ways to check if a positive number is equal to zero?

Yes, there are other ways to check if a positive number is equal to zero. Some programming languages have built-in functions or methods specifically designed for this purpose. For example, in JavaScript, the Number.isZero() method can be used to check if a number is equal to zero.

Similar threads

  • Linear and Abstract Algebra
Replies
1
Views
490
  • Linear and Abstract Algebra
Replies
19
Views
2K
  • Linear and Abstract Algebra
2
Replies
41
Views
2K
  • Linear and Abstract Algebra
Replies
13
Views
1K
  • Linear and Abstract Algebra
Replies
11
Views
1K
  • Linear and Abstract Algebra
Replies
8
Views
772
  • Linear and Abstract Algebra
Replies
5
Views
985
  • Linear and Abstract Algebra
Replies
1
Views
708
  • Linear and Abstract Algebra
Replies
8
Views
1K
Replies
2
Views
940
Back
Top