Checking weather any positive number is zero or not


by Lslander
Tags: checking, number, positive, weather
Lslander
Lslander is offline
#1
Jul1-11, 12:00 PM
P: 2
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...
Phys.Org News Partner Science news on Phys.org
Better thermal-imaging lens from waste sulfur
Hackathon team's GoogolPlex gives Siri extra powers
Bright points in Sun's atmosphere mark patterns deep in its interior
Floid
Floid is offline
#2
Jul1-11, 12:38 PM
P: 235
"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...
gb7nash
gb7nash is offline
#3
Jul1-11, 01:17 PM
HW Helper
P: 805
Quote Quote by Lslander View Post
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.

Quote Quote by Lslander View Post
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.

Quote Quote by Lslander View Post
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.

Quote Quote by Lslander View Post
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?

Lslander
Lslander is offline
#4
Jul1-11, 05:28 PM
P: 2

Checking weather any positive number is zero or not


Quote Quote by gb7nash View Post
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...
kid1
kid1 is offline
#5
Jul6-11, 12:52 AM
P: 3
f(x) = x^0 works but I don't know if that's quite what you're looking for.
dimension10
dimension10 is offline
#6
Jul6-11, 07:28 AM
P: 371
Quote Quote by gb7nash View Post
Why not f(n) = [n/(n+1)], where [] is the ceiling function?
Isn't the ceiling function notation ⌈x⌉ rather than the whole [x]
gb7nash
gb7nash is offline
#7
Jul6-11, 07:33 AM
HW Helper
P: 805
Quote Quote by dimension10 View Post
Isn't the ceiling function notation ⌈x⌉ rather than the whole [x]
Yes, but I can't find ⌈⌉ on the keyboard.


Register to reply

Related Discussions
Why is (n^0=1)? where n is any positive number General Math 6
Checking the answer to complex number question Calculus & Beyond Homework 1
Checking the weather General Discussion 8
Is 0 is an even and positive number? General Math 10