0
$\begingroup$

i need a mathematical function F which is defined as F(x) = 0 if x equal to zero and F(x) = 1 if x is not equal to zero. can F(x) be represented in the form of a single mathematical expression in terms of x?

  • 0
    Anil has not returned since Feb 25, so no-one knows what he means by "mathematical expression".2011-07-23

2 Answers 2

5

Knuth suggests using the Iverson bracket notation $[x\ne0]$ for that function. You can also try $|\mbox{sgn}(x)|$. See http://en.wikipedia.org/wiki/Sign_function

0

Any algorithm that does what you want will be dependent upon the F(x) you are working with. Some F's are easy-for x^2 you can take the integer sqrt of x, square it, and see if you get x back again. For x^x you could just store a table of them up to the largest number of interest and search the table. Unless you are doing arbitrary precision work it will be much less than 1000 entries.