Or simply $$(-1)^n$$, which gives 1 if n is even and -1 if n is odd. If you want 0 and 1 you can use:$$\cos^2{(\frac{\pi}{2}n)}$$
Those are just due to the usual numerical errors: I'd expect both $$\pi x$$ and $$\cos(x)$$ are less accurately calculated/stored for large $$x$$.Only problem I see is that when the odd numbers get large, it shows that its not really 0, just incredibly small values.
Or work in binary:$$z = 10*\lfloor \frac{x}{10} \rfloor - x $$
(n\2)AND(n/2)?I was just interested in an algebraic method of testing numbers for even or oddness which yields a boolean response, like 1 or 0, but it could be any two values.
Then I suppose there's stuff like this:
$$\int^{\infty}_{-\infty} f_n(x) \triangle_2(x) \mathrm{d}x$$
$$f_n(x) \: \equiv \: \left{ 1 \; \mathrm{if} \; x = n \\ 0 \; \mathrm{if} \; x \neq n \right.$$ (indicator function of n)
$$\triangle_2(x) \: \equiv \: \sum^{\infty}_{k = -\infty} \delta(x - 2k)$$ (Dirac comb of period 2)
Well it would give a boolean response, since it is the logical AND, 1 AND 1 = 1, 0 AND 1 = 0Przyk : Whats that funky symbol mean? The one that looks kinda like an R in your original post
Cyperium: Yes, but I was looking for a boolean response, the reason for which was discussed further on.
$$\Re(z)$$ designates the real part of the complex number $$z$$. If you have a complex number $$z = a + b i$$ (where $$a$$ and $$b$$ are real), then $$\Re(z) = a$$.Przyk : Whats that funky symbol mean? The one that looks kinda like an R in your original post
Unless I'm being over-sloppy somewhere,That integal's value is zero since f_n(x) = 0 for all but 1 value.
Ah, well, gives me an excuse to make things more complicated.... for all continuous f
Are you sure it's not the equality test you're thinking of? "n\2 == n/2.0" should return "true" if n is even and "false" otherwise.Well it would give a boolean response, since it is the logical AND, 1 AND 1 = 1, 0 AND 1 = 0
Yes, in a programming language. In a circuit the logical AND would work (if the number is translated binary of course).Are you sure it's not the equality test you're thinking of? "n\2 == n/2.0" should return "true" if n is even and "false" otherwise.
What do you mean by this?if the number is translated binary of course