# pouët.net

Go to bottom

## Math stupid question on continuous curve

category: general [glöplog]
WTF ?
http://www.iquilezles.org/apps/graphtoy/
Ok I'm 35 and my few math skills are lost in space, but:
On Iq's toygraph site, I'm quite fascinated by f(x)=sin(4*x)/x.
How a function with 1/x can "look" continuous for 0 ?
It is not continuous right ? ...but you can zoom in the top of the curve with iq's interface ... and it really looks continuous !!!

- Someone with fresher brain got a smart answer to this ?
- Do you know other simple equations with 1/x that avoid "discontinuity" ?
added on the 2010-02-16 12:09:49 by krabob
well, a tiny amount either side of zero and it heads towards 4. At zero, you get a div0 error so I guess that result is thrown away (or a tiny number is added to zero). Otherwise, yes, if you zoom in an infinite amount you'll see a gap for sure. Keep zooming in :)
added on the 2010-02-16 12:32:42 by psonice
lim sin(x) / x = 1
x -> 0

Some explainations, I didn't search much though.
added on the 2010-02-16 12:33:51 by Twinside
That explain the continuous look, and only that. (it should be discontinuous on 0)
added on the 2010-02-16 12:35:17 by Twinside
Quote:
How a function with 1/x can "look" continuous for 0 ?

Take f(x) = x / x. When stated like that, it's 1 everywhere except at 0, where it's undefined. If you simplify it to 1, you get a function that's well-defined everywhere.

Same case with sinc. The expression sin(x)/x is undefined at x=0, but the 'patched' function "f(x) = sin(x)/x if x!=0, 1 if x=0" is defined over the real line and continuous everywhere. Furthermore, lim x->0 sin(x)/x=1. Note that neither the original nor the patched function have any discontinuities! Both are continuous over their whole domain; it's just that the expression sin(x)/x is undefined for x=0. When you have a single-point "hole" in the domain of a function for which a limit exists, it's called a "removable" or "cosmetic" singularity - you can easily define a modified function that agrees with the original function everywhere and includes the undefined point in its domain. The "x/x" I mentioned earlier is a trivial example of this. It's customary to present such functions with the easiest algebraic equation that defines them almost everywhere (in this case meaning, everywhere except for at most a countable number of removable singularities) and insert the necessary limits as necessary. Just take it as a somewhat sloppy but generally accepted shorthand.

A straightforward analytical way to see that lim x->0 sin(x) / x = 1 is to just plug it into the analytical definition of sin.

Code:```sin(x) = sum(k=0;inf) (-1)^k x^(2k+1) / (2k+1)! => sin(x)/x = sum(k=0;inf) (-1)^k x^(2k) / (2k+1)! = 1 - (x^2)/3! + (x^4)/5! - (x^6)/7! + ...```

which is a power series that is both well-defined and convergent for x=0 and evaluates to 1 there (as should be obvious from the series expansion).
added on the 2010-02-16 14:35:15 by ryg
thanks for the interesting explainations twinside & ryg, I have to remember some stuffs about limits I guess...
added on the 2010-02-16 15:43:31 by krabob
It's called a removable singularity.
added on the 2010-02-16 17:44:07 by imbusy
Quote:
A straightforward analytical way to see that lim x->0 sin(x) / x = 1 is to just plug it into the analytical definition of sin.

Series sucks, go French and use L'Hopital
added on the 2010-02-16 17:50:18 by px
ah ja, hospitalsreglen
Yes, mr.Hospital is what I thought when first seeing this function. But I haven't thought this before: it makes sense mathematically but it bugs me now how would you evaluate this on code? (it would divide zero by zero if you just replace x by zero). Gotta read the explanations cause they are interesting (and different ways to look at it than L'Hopital).
added on the 2010-02-16 18:12:58 by Optimonk
Ok, I see. You just discard the case where it's exactly zero. When it's very very close to zero, you get a sin(x) that is very similar to x, so dividing the two gets one. There is no really anything to plot at exact zero even if you would make the graph plot looks continuous near zero.
added on the 2010-02-16 18:17:56 by Optimonk
krabob, GraphToy discards infinites and NaNs by not drawing anything. Thing is you will hardly ever get an exact x=0 anyway (for the sin(4x)/x I mean), you must be really unlucky for a pixel to perfectly match x=0.

Even if it did, since x=0 is a removable singularity (limit in the left = limit in the right) only one pixel would be empty in the graph. Now, GraphToy draw lines with a width of 1.5 pixels, so the curve in the left and the curve in the right will account for the 0.5+0.5 = 1 pixel missing effectively filling the removable hole.

btw, at school we learned to solve the 0/0 cases by L'Hopital indeed, is not like that everywhere else, or are the countries renaming again the theorems for (old) political reasons?
added on the 2010-02-16 18:54:14 by iq
You can not use L'Hopital's rule, because the evaluation of the derivative of sin(x) uses the limit sin(x)/x as x->0. Circular proof.
added on the 2010-02-16 19:13:15 by imbusy
i dont know iq release that stuff. clean interface, do what is it supposed to be, rocks solid (like shadertoy...). thx iq
added on the 2010-02-16 19:24:46 by Tigrou
and oh yeah
i forgot :
added on the 2010-02-16 19:26:46 by Tigrou
not sure, in fact it's a double limit: in two variables, isn't it?

lim(x->0, sin(x)/x) = lim( x->0, lim(y->0, sin(x+y)-sin(x)) / 1 ) and by exanding sin(x+y) in sinx*siny + cosx*cosy you get the same as directly appying L'Hopital lim(x->0, sin(x)/x) = lim( x->0, sin'(x) / x' )= lim(x->0,cos(x)/1) = 1/1 = 1
added on the 2010-02-16 19:39:52 by iq
I used the series expansion since you actually see what's going on, L'Hopital is easier to do mechanically but offers no insight. Not what I'm going for in an explanation :)
added on the 2010-02-16 19:44:18 by ryg
very true
added on the 2010-02-16 20:21:36 by iq
btw, that's how Wikipedia has chosen to exemplify what a removable singularity is (with the very same sin(z)/z ). link me beautiful
added on the 2010-02-16 20:23:54 by iq
imbusy, that would be a problem if using sin(x)/x -> 0 was the only way to determine that sin' = cos, but it's not. For example, you can compute the derivative of sin by formally differentiating its power series, which turns into the power series for cos, establishing the identity both algebraically and analytically. You can use sin(x) = im(exp(ix)) = (exp(ix) - exp(-ix)) / 2i which implies sin'(x) = (i exp(ix) - (-i) exp(-ix)) / 2i = (exp(ix) + exp(-ix)) / 2 = re(exp(ix)) = cos(x) - I really like this one. And there's definitely tons of other ways.
added on the 2010-02-16 20:57:17 by ryg