Wikipedia:Reference desk/Archives/Mathematics/2009 June 18

= June 18 =

Converting a floating point number to an integer using basic arithmetic
Is there a way to convert a floating point number to an integer (what int would do) using only arithmetic functions (+ - / * % and ^)? And while I guess I could loop it subtracting fractions of an integer, I don't have any function to test whether the number is an integer (or floating point) until I've finished. This seems like the kind of problem that would have an answer, either that it's impossible or that it is possible. Anyone know which? Shadowjams (talk) 06:04, 18 June 2009 (UTC)


 * You cannot do it with any continuous combination of continuous operations, because there are no nonconstant continuous functions from the reals to the integers. &mdash; Carl (CBM · talk) 06:10, 18 June 2009 (UTC)


 * My pure math background is very outdated, so bear with me. When you say continuous operations, do you mean the arithmetic functions (and maybe others)? What kind of function do you need to actually do this? Shadowjams (talk) 06:29, 18 June 2009 (UTC)


 * All the arithmetical operations are continuous. In an actual computer, the floor operation can look directly at the bits of the floating point number to get the corresponding integer; it does not have to do any arithmetical manipulations. &mdash; Carl (CBM · talk) 06:36, 18 June 2009 (UTC)

Can you test whether your float is larger than a given integer? If you then a crude solution is to start on 1 and increment by 1 until the integer is larger than the float. Then subtract 1, and you have the answer. Taemyr (talk) 07:00, 18 June 2009 (UTC)
 * Hm Good point. Actually, I'm trying to do this in Yahoo Pipes, so no, I don't think that I can test any of the arithmetic conditions, although there might be a very convoluted way to use a regular expression to check what you're talking about, but I'm not sure I can do it an indefinite number of times, so there's no elegant solution apparently. Shadowjams (talk) 07:25, 18 June 2009 (UTC)

If the "%" you listed above is floating point mod, then floor(x) = x - (x % 1), for positive real numbers. Dragons flight (talk) 07:35, 18 June 2009 (UTC)


 * That would actually give the nearest integer using IEEE floating point standard remainder operation which gives the exact value of x-(round(x/y)*y) irrespective of rounding mode. The result of the mod can be positive or negative irrespective of whether the two operand are positive. Dmcq (talk) 10:11, 18 June 2009 (UTC)
 * Actually the whole business of the Modulo operation and Remainder is a bit of a mess and you need to check which one the compiler implements in any particular computer language even for integers. Dmcq (talk) 10:17, 18 June 2009 (UTC)


 * I see you want to do this in reality on a system that only provides those operations. What an idea, reality, must think about that. Oh okay then what you can do is multiply by the smallest possible Denormal number and then divide by it again. This will unfortunately round to nearest but for positive numbers you can compensate somewhat by subtracting just less than 0.5 to start with. Exactly 0.5 would turn 3 into 2. Dmcq (talk) 10:51, 18 June 2009 (UTC)
 * If you want a different rounding mode you can fix it up afterwards, e.g. if (result > n) --result; if you want to round to -∞. In C, nextafter(0,1) will return the smallest positive double (and there are similar functions for float and long double). Some implementations use a wider format for intermediate results (including many x86 compilers), and to get around that you would have to assign the intermediate result to a volatile variable or some such. Some implementations don't support denormals and on those this trick won't work. -- BenRG (talk) 11:24, 18 June 2009 (UTC)
 * The denormal article doesn't give the values for float of 1.5e-45 and double 5e-324. As BenRG says there can be problems and even if it works in C the performance can be dreadful. Try it out and you will feel the power of the dark side of computing. Dmcq (talk) 12:29, 18 June 2009 (UTC)
 * I think I'd try the floor(x) = x - (x % 1) of Dragons flight first. The system may not implement % for float but my guess is that they do. Dmcq (talk) 13:33, 18 June 2009 (UTC)

Interior
WRT Interior (topology), is it true that Set S comprises the interior points + the boundary points? Is the boundary of the complement of Set S the same as the boundary of Set S? If not, how can the exterior of S be the interior of the complement of S? -- SGBailey (talk) 10:19, 18 June 2009 (UTC)


 * No, a set does not have to include its boundary, unless it is closed. Yes, the boundaries of any set and its complement are the same. In any case, the exterior of a set is defined to be the interior of its complement, so it is meaningless to ask "how can be". — Emil J. 10:33, 18 June 2009 (UTC)


 * What do you mean by "Set S"? Do you mean the underlying set of the topological (sub)space S? If so, it doesn't have a boundary, that is a topological concept. --Tango (talk) 13:57, 18 June 2009 (UTC)


 * I don't know what I mean by Set S. See Interior (topology) where it is defined. -- SGBailey (talk) 15:40, 18 June 2009 (UTC)
 * Sometimes a set is just a set. For example, if our topological space is $$\mathbb{R}^2$$ with its usual topology then S can be $$\{(x,y)|x^2+y^2<1\}\,\!$$. -- Meni Rosenfeld (talk) 16:01, 18 June 2009 (UTC)
 * I don't see "Set S" mentioned in the article, did you just mean "a set called S"? The way you wrote it made it look like "Set" was some operator acting on S. --Tango (talk) 01:56, 19 June 2009 (UTC)
 * Words 7 and 8 in the lead. Yes, it just means a set called S. -- Meni Rosenfeld (talk) 15:45, 19 June 2009 (UTC)

Continuous functions without known primitive ?
Helo maths lovers !

Please excuse my poor English, I'm French. I got very few informations for the following question in the French Wikipedia. It seems that your desk is more active.

When I was a student, I learnt methodes to calculate an approximative value for an integration (such the Simpson methode) because we were taught that many continuous functions have no known primitive.

The strange thing is that I can give only 2 or 3 examples of such functions :

The well knonw f(x)= exp(-x²) and others of the same type

g(x)=cos(x²)

and g(θ)= square root(a²cos²θ + b²sin²θ) with wich one can calculate the perimeter of an ellipse.

Who could give other examples ? thank you very much for your attentions. Joël DESHAIES, in Reims, France. --82.216.144.50 (talk) 13:56, 18 June 2009 (UTC)


 * "No known primitive" is an incorrect term. These are just functions whose primitive is not in a somewhat arbitrary family of functions which are called "elementary" and commonly featured in calculators. A primitive of $$\exp(-x^2)\,\!$$ is $$\tfrac12\sqrt{\pi}\mathrm{erf}(x)$$, where $$\mathrm{erf}\,\!$$ is the error function, a "non-elementary" function.
 * So the correct question should have been about functions whose primitives are not elementary. There is no shortage of examples - in fact, I think "most" functions have no elementary primitive. For instance, virtually any function of the form $$\exp(f(x))\,\!$$ where f is not linear or logarithmic ($$\exp(x^2),\exp(x^3),\exp(\cos x),\exp(\exp(x)),\exp(x\log x)=x^x,\ldots$$). Same goes if you use $$\cos$$ or $$\sin$$ instead of $$\exp$$. -- Meni Rosenfeld (talk) 14:49, 18 June 2009 (UTC)
 * (ec)Some of these functions, like $$x^x$$, do not even have a primitive in terms of special functions. But this is not because the primitive is somehow "unknown", but only because nobody deemed this primitive function important enough to bother with giving it a name. -- Meni Rosenfeld (talk) 15:01, 18 June 2009 (UTC)
 * What proportion of continuous functions are even integrable? --Tango (talk) 14:52, 18 June 2009 (UTC)
 * All of them. Algebraist 14:56, 18 June 2009 (UTC)
 * If they are defined over the whole real line, maybe, but what about functions with singularities? Not all improper integrals converge. --Tango (talk) 15:08, 18 June 2009 (UTC)
 * In the context of a primitive (i.e. $$\textstyle\int_0^t f(x)\,dx$$), it's enough for the function to be continuous on an open set, in which case one will get a primitive at every point of continuity. Characterizing which discontinuous functions are derivatives (even at their points of discontinuity) is a much harder question. &mdash; Carl (CBM · talk) 15:16, 18 June 2009 (UTC)
 * True, in the context of primitives it doesn't really matter. You wouldn't expect the function to have a primitive where it isn't defined. --Tango (talk) 15:35, 18 June 2009 (UTC)
 * It's still an interesting question (e.g. 1/x and ln(|x|) work). But Darboux's theorem (analysis) is the only result I know in the area. &mdash; Carl (CBM · talk) 16:04, 18 June 2009 (UTC)


 * See Nonelementary integral. A large proportion of named functions in applied mathematics were invented as the solution of an interesting integral. Dmcq (talk) 14:59, 18 June 2009 (UTC)
 * Another approach: elementary functions are smooth, so only smooth functions can have elementary primitives, while piecewise smooth functions might have piecewise elementary primitives (I think it's fair to say a piecewise elementary primitive is still a 'known' primitive). Thus any sufficiently horrible continuous function will not have a (piecewise) elementary primitive. Since almost all continuous functions are nowhere differentiable, this gives lots of examples. Algebraist 15:02, 18 June 2009 (UTC)


 * See the Risch algorithm article for some references about this. Finding elementary antiderivatives is sort of like finding roots of polynomials in terms of radicals, in that a lot of them can't be solved that way, and there's a theory sort of like Galois theory that tells you which ones are solvable and which ones aren't. 208.70.31.186 (talk) 17:40, 18 June 2009 (UTC)

Notice that there are functions that are not differentiable, or not even continuous, yet, whose integral function has a nice representation. To mention two classes of examples: functions defined by a Fourier series; or functions defined as solution of a functional equation: they may be very discontinuous, yet their integral function may be deduced from the Fourier series, resp. from the functional equation. --84.221.208.172 (talk) 22:57, 18 June 2009 (UTC)

The torus double-covers the sphere
In this thread it was explained that the torus double-covers the sphere with four "ramification points". In the article titled torus that is also pointed out.

I wondered if it's possible to do away with the ramification points and find a two-to-one continuous mapping from the torus to the sphere that's locally one-to-one everywhere, like a circle getting mapped twice around another circle.

So I thought: Jacobian elliptic functions are doubly periodic, so their domain can be considered a torus, and they map into the Riemann sphere and assume every value twice, so maybe that would do it, and the mapping would be conformal. But then I realized: these functions do have points where the derivative is zero. They assume every value twice if you count by multiplicities, and at those points the multiplicity is 2, and the mapping is neither locally one-to-one nor conformal at those points. And if I'm not mistaken, there are four of them.

So my question: is the thing I had in mind provably impossible?

If so, I think maybe that fact should be stated explicitly in the torus article, with a reference to the literature. Michael Hardy (talk) 18:23, 18 June 2009 (UTC)


 * This just follows from the Riemann-Hurwitz formula: if your map $$ \mathbb{T} \to \hat{\mathbb{C}} $$ has degree $$ d $$, then the number of branch points is
 * $$ b = d \chi(\hat{\mathbb{C}}) - \chi(\mathbb{T}) = 2 \times 2 - 0 = 4 $$
 * where $$ \chi $$ is the Euler characteristic.
 * I guess another way of seeing this is that we know that any nonconstant elliptic function must have at least 2 poles (with multiplicities) so must have degree at least 2 as a map to the Riemann sphere. Then its derivative must have at least 3 (this is the case for the derivative of the Weierstrass $ \wp$ function). It also has to be branched over infinity (though I'm not totally sure why yet), so that you get the required four branch points, and this is the minimum possible. --XediTalk 21:06, 18 June 2009 (UTC)

The Riemann–Hurwitz article seems to cover it. Thank you.

Next task: what's the best way to incorporate this information into the torus article? Maybe I'll do that soon. Michael Hardy (talk) 02:28, 19 June 2009 (UTC)
 * It seems a local homeomorphism, a covering space map, is being described. A torus, or any other connected manifold, covering a sphere without ramification points is impossible because the sphere is simply connected - and so its own universal Covering space. The fundamental group of a nice space is the same as the automorphism group of its universal covering space. So no analyticity assumption is necessary.John Z (talk) 04:10, 20 June 2009 (UTC)

This last proposed reason why no such covering is possible seems simpler than the one that Xedi proposed.

If by "analyticity" you mean that it's conformal, I certainly never thought that was necessary. Michael Hardy (talk) 19:58, 20 June 2009 (UTC)