Page 1 of 1

x - cos(x) = 0

Posted: Thu Jan 15, 2009 12:40 am UTC
by tricky77puzzle
Is there an algebraic way to define the answer? The answer I get is:

0.73908513321516064165531208767387 (using radians, of course.)

but I don't know if there's a way to define this using a function or any special constants. Can anyone help? (No, this is not homework, they don't teach this kind of thing in Grade 10.)

Re: x - cos(x) = 0

Posted: Thu Jan 15, 2009 12:49 am UTC
by ++$_
Not really, no.

If you rewrite that expression as x = cos(x), you can see that any solution is equal to [imath]\lim_{n \to \infty}cos^{(n)}(x_0),[/imath] if this exists (and it does). However, that's an even less-closed form than the original one.

(Note: [imath]\cos^{(n)}(x)[/imath] is what you get by applying the cosine function to [imath]x[/imath] [imath]n[/imath] times.)

Re: x - cos(x) = 0

Posted: Thu Jan 15, 2009 1:01 am UTC
by Ended
It's called the Dottie number.

"It was named after a French professor who noticed that whenever she typed a number into her calculator and hit the cosine button over and over, the result always converged to this value." :|

Re: x - cos(x) = 0

Posted: Thu Jan 15, 2009 1:13 am UTC
by t0rajir0u
Most random functions you can write down don't have "nice" inverses. In fact, you should almost never expect this happen, especially if you're mixing polynomials with anything that's not a polynomial. Instead, we have to do things like define whatever we come across as a new function in its own right (at least if it's interesting enough).

Re: x - cos(x) = 0

Posted: Thu Jan 15, 2009 1:34 am UTC
by NathanielJ
Here's a thread with some discussion on the Dottie number:

http://forums.xkcd.com/viewtopic.php?f=17&t=23066&p=687416

Re: x - cos(x) = 0

Posted: Thu Jan 15, 2009 5:28 am UTC
by cspirou
You won't find an algebraic expression because it's a transcendental function. You can only solve for x when it's a finite polynomial. same thing goes for x=5^x.

Re: x - cos(x) = 0

Posted: Thu Jan 15, 2009 5:33 am UTC
by t0rajir0u
That depends on what is meant by "algebraic." Usually it means "in terms of elementary functions," and once you realize this you have to realize that the definition of the set of elementary functions is totally arbitrary.

For example, if you only allow radicals and basic arithmetic in your elementary functions, you can't invert general fifth-degree polynomials and higher. (Some people misinterpret Abel's theorem; it is possible to solve quintic polynomials in closed form if you allow either Bring radicals or elliptic functions.) If you allow the Lambert W function, it is (I believe) in fact possible to solve [imath]x = 5^x[/imath].

Re: x - cos(x) = 0

Posted: Thu Jan 15, 2009 6:05 am UTC
by Rentsy
Most of the time, when there is a variable inside a trig function and a variable outside of a trig function, you can't find the answer, not algebraicly.

I did have to deal with [imath]2x - sinx = 0[/imath] once, and solved it by noticing at at 0, both functions were 0. Oh, the origin...

Re: x - cos(x) = 0

Posted: Thu Jan 15, 2009 10:55 am UTC
by Cosmologicon
Rentsy wrote:I did have to deal with [imath]2x - sinx = 0[/imath] once, and solved it by noticing at at 0, both functions were 0. Oh, the origin...

Yes, I noticed that if I kept hitting sin and then dividing by 2 on my calculator, it would always approach 0. That's why the mysterious number 0 is called the Cosmologicon number.

Re: x - cos(x) = 0

Posted: Thu Jan 15, 2009 7:00 pm UTC
by Ended
Cosmologicon wrote:That's why the mysterious number 0 is called the Cosmologicon number.

The Mathematics Council might not be too happy with that.

Re: x - cos(x) = 0

Posted: Thu Jan 15, 2009 11:21 pm UTC
by tricky77puzzle
Ended wrote:
Cosmologicon wrote:That's why the mysterious number 0 is called the Cosmologicon number.

The Mathematics Council might not be too happy with that.

Ah... so why is cos so special...? I'll try "cot" next.

Re: x - cos(x) = 0

Posted: Fri Jan 16, 2009 5:57 am UTC
by t0rajir0u
It's not. You'll figure out why it works if you graph x - cos x = 0 on a calculator. The result is true essentially because the two graphs x and cos x only intersect once. You can do the same thing with, say, x + 1 = sin x.

Re: x - cos(x) = 0

Posted: Wed Jan 21, 2009 12:22 pm UTC
by Beacons!
NathanielJ wrote:Here's a thread with some discussion on the Dottie number:

http://forums.xkcd.com/viewtopic.php?f=17&t=23066&p=687416


Aww, my first ever topic is being referenced. How Cute.

Re: x - cos(x) = 0

Posted: Mon Jan 26, 2009 6:52 am UTC
by cspirou
It gets attracted to that point because it's an iterative mapping.

http://hypertextbook.com/chaos/11.shtml

Re: x - cos(x) = 0

Posted: Mon Jan 26, 2009 7:05 pm UTC
by t0rajir0u
The fact that it's iterative says nothing about whether it has any attractors. There are plenty of examples of iterative mappings with no attractors (in [imath]\mathbb{R}[/imath]), for example [imath]f(x) = x^2 + 1[/imath].

Re: x - cos(x) = 0

Posted: Tue Jan 27, 2009 1:51 pm UTC
by A_of_s_t
tricky77puzzle wrote:Is there an algebraic way to define the answer?

The only way that comes to mind is Newton's method which involves some calculus:

n2 = n1 - f(n1)/f'(n1)

Which is, in your case:

n2 = n1 - (n1 - cos(n1) / 1 + sin(n1) )

What you do is pick any number near the zero and plug it into n1 and solve for n2. Then do the same thing for n2 and untill you get to na where is a is the amount of "iterations" you want. The more you do, the closer the answer gets to being the value x is for x - cosx = 0. Either the answer will be very close, or it will be the exact answer.

Hope that helps :/

Re: x - cos(x) = 0

Posted: Tue Jan 27, 2009 2:09 pm UTC
by Cosmologicon
You can also just do n2 = cos(n1). No calculus needed.

Re: x - cos(x) = 0

Posted: Tue Jan 27, 2009 3:56 pm UTC
by PM 2Ring
Cosmologicon wrote:You can also just do n2 = cos(n1). No calculus needed.


Certainly! But it takes ages to converge. If we use Newton's method, it converges rather rapidly. After the first couple of iterations, the number of correct digits doubles at each step. I tried this a few days ago using bc & was most impressed with its speed.

FWIW, I first encountered this "Dottie's Number" in the mid-70s, in high school calculus. Our class was the first one in our school to have access to scientific calculators, and one of the guys stumbled across this number one day, just playing around like Ms Dottie did. So I don't know why she should get naming rights. :)

Re: x - cos(x) = 0

Posted: Tue Jan 27, 2009 4:14 pm UTC
by jestingrabbit
PM 2Ring wrote:Prof. Dottie


Fixed and I think that's probably part of why the name is what it is.

Re: x - cos(x) = 0

Posted: Tue Jan 27, 2009 4:37 pm UTC
by PM 2Ring
jestingrabbit wrote:
PM 2Ring wrote:Prof. Dottie


Fixed and I think that's probably part of why the name is what it is.


And my high school colleague never published his result, so his chance of glory was lost. Thus is the lot of the 'umble amateur. :)

Speaking of iterating cos, Julia sets of complex trig functions can look quite pretty. I have a few pics in an old fractal book here. I might fire up FRACTINT later, and see what z' = cos(z) looks like in the neighbourhood of Dottie's number.

Re: x - cos(x) = 0

Posted: Tue Jan 27, 2009 9:35 pm UTC
by bray
I think there are two kinds of people in the world. Those who like a computer program that doubles the number of correct digits with each step, and those who like that with a couple minutes of work by hand (and, okay, I'll admit it, extensive simplification by maple), you can get that it's approximately:

[math]\frac{\sqrt{232 - 117 \sqrt{3}} + 6 \sqrt{3} - 13}{3 (3 - \sqrt{3})}[/math]

Good within 0.05%! If you really hate computers, you can just go with [imath]\sqrt{3} - 1[/imath] which gets you within roughly 1%. Not too shabby.

Re: x - cos(x) = 0

Posted: Tue Jan 27, 2009 9:59 pm UTC
by NathanielJ
bray wrote:I think there are two kinds of people in the world. Those who like a computer program that doubles the number of correct digits with each step, and those who like that with a couple minutes of work by hand (and, okay, I'll admit it, extensive simplification by maple), you can get that it's approximately:

[math]\frac{\sqrt{232 - 117 \sqrt{3}} + 6 \sqrt{3} - 13}{3 (3 - \sqrt{3})}[/math]

Good within 0.05%!


What good is an approximation if it's an obtuse approximation? Exact answers are nice because they are exact. Approximations are nice because they allow us to see at a glance what the number (roughly) is. That approximation is significantly worse than the decimal approximation given in the first post though, and reveals much less about its value.

If you want something within 0.05%, you might as well just use 73909/100000 or some such thing.

Re: x - cos(x) = 0

Posted: Tue Jan 27, 2009 10:28 pm UTC
by bray
NathanielJ wrote:If you want something within 0.05%, you might as well just use 73909/100000 or some such thing.


Err...I'm not really sure how to respond to this. Different strokes for different folks, basically. But, really, where did that "73909" come from? An approximation, one presumes? An approximation that probably involved evaluating lots of transcendental functions and so forth. Yeah, I could have just gone with cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(0.5))))))))))) and gotten something about as accurate. But I wanted something I could compute by hand. Something without all those damn transcendental functions. And I got it.

Is it pointless? Yes, of course. But this is the Mathematics forum, guy.

Re: x - cos(x) = 0

Posted: Wed Jan 28, 2009 12:04 am UTC
by jestingrabbit
I can see the attraction of bray's radicals answer. I could construct a right triangle with that side length ratio using a straight edge and compass.

Re: x - cos(x) = 0

Posted: Wed Jan 28, 2009 12:14 am UTC
by 0xDEADBEEF
This certainly isn't algebraic, and isn't as accurate as the result posted by the OP, but I had fun knocking this out, and that's what matters!

Code: Select all

#!/usr/bin/python

import math

hi = math.pi / 2.0
lo = 0
x = (lo + hi) / 2.0

while x > lo and x < hi:
        y = math.cos(x)

        if y < x:
                hi = x
                x = (lo + hi)/ 2.0
        else:
                lo = x
                x = (lo + hi) / 2.0
     
print y


Edit: As I read...
Ended wrote:It's called the Dottie number.

"It was named after a French professor who noticed that whenever she typed a number into her calculator and hit the cosine button over and over, the result always converged to this value." :|
... it becomes apparent that I should change my algorithm.

Code: Select all

#!/usr/bin/python
import math

y = 0.5
x = 0

while x != y:
    x = y
    y = math.cos(x)

print y

Re: x - cos(x) = 0

Posted: Wed Jan 28, 2009 12:47 am UTC
by NathanielJ
bray wrote:But I wanted something I could compute by hand.


Ah, I missed the "by hand" part. I thought you just fiddled around with Maple and got that as an approximation to Dottie's number. Comment retracted.

Re: x - cos(x) = 0

Posted: Wed Jan 28, 2009 7:43 am UTC
by Macbi
bray wrote:Good within 0.05%! If you really hate computers, you can just go with [imath]\sqrt{3} - 1[/imath] which gets you within roughly 1%. Not too shabby.
I'm going with 14/19, good to 0.3%!

Re: x - cos(x) = 0

Posted: Wed Jan 28, 2009 8:21 am UTC
by qinwamascot
7093/9597 is much closer. I'm going with that for now.

Re: x - cos(x) = 0

Posted: Wed Jan 28, 2009 9:13 am UTC
by jaap
Macbi wrote:
bray wrote:Good within 0.05%! If you really hate computers, you can just go with [imath]\sqrt{3} - 1[/imath] which gets you within roughly 1%. Not too shabby.
I'm going with 14/19, good to 0.3%!


I'd use 17/23 instead. The same number of digits to remember, but it is about 0.006% accurate.
Or else 711/962 to get to about 1e-7 from the right value.

Re: x - cos(x) = 0

Posted: Sat Jan 31, 2009 10:28 am UTC
by uewebawo
you could always do the Taylor Series of 0 = -x + cos(x)...

something like 0 = -x + 1 - x^2/2! + x^4/4! - x^6/6! + ... + (-1)^n * x^2n/(2n)! + ...

although i don't think that gains you anything in solving for x, but it would be "algebraic"

pardon my weak skills at formatting.

Re: x - cos(x) = 0

Posted: Sat Jan 31, 2009 10:58 am UTC
by Macbi
uewebawo wrote:you could always do the Taylor Series of 0 = -x + cos(x)...

something like 0 = -x + 1 - x^2/2! + x^4/4! - x^6/6! + ... + (-1)^n * x^2n/(2n)! + ...

although i don't think that gains you anything in solving for x, but it would be "algebraic"

pardon my weak skills at formatting.

I imagine that's what bray did to get his insane representation up there. Probably taking the first 5 terms and
solving the quartic. Am I right?

Re: x - cos(x) = 0

Posted: Tue Feb 03, 2009 1:04 am UTC
by bray
NathanielJ wrote:
bray wrote:But I wanted something I could compute by hand.


Ah, I missed the "by hand" part. I thought you just fiddled around with Maple and got that as an approximation to Dottie's number. Comment retracted.


Ah good, I was highly confused for a while there. Retraction noted.

Macbi wrote:
uewebawo wrote:you could always do the Taylor Series of 0 = -x + cos(x)...

something like 0 = -x + 1 - x^2/2! + x^4/4! - x^6/6! + ... + (-1)^n * x^2n/(2n)! + ...

although i don't think that gains you anything in solving for x, but it would be "algebraic"

pardon my weak skills at formatting.

I imagine that's what bray did to get his insane representation up there. Probably taking the first 5 terms and
solving the quartic. Am I right?


Pretty close! The solution to the quartic is much crazier looking and has the disadvantage that it can't really be worked out by hand (unless one happens to know the quartic formula and I certainly don't). In a nutshell: the first (probably obvious by now) step was to just take the first three terms and solve the resulting quadratic. That's what gives the simple (and perhaps surprisingly good) approximation [imath]\sqrt{3} - 1[/imath]. Then I tried to approximate how tacking on that [imath]\frac{x^4}{4!}[/imath] would shift the answer. So letting [imath]a = \sqrt{3} - 1[/imath], we have
[math]0 = -24 (a + \Delta a) + 24 - 12 (a + \Delta a)^2 + (a + \Delta a)^4 \approx -24 (a + \Delta a) + 24 - 12 (a + \Delta a)^2 + a^4 + 4 a^3 \Delta a + 6 a^2 \Delta a^2[/math].
Solving that quadratic (a bunch of the terms there disappear when you use the fact that a is a root of the original quadratic) for [imath]\Delta a[/imath] gives my insane approximation from before.

And, yes, folks, there are lots of other simpler/rational numbers which approximate the Dottie number better. If you'd like to post your derivation for them, please go ahead.

Re: x - cos(x) = 0

Posted: Tue Feb 03, 2009 4:44 pm UTC
by t0rajir0u
Why? With enough digits it's trivial to compute the continued fraction representation of the Dottie number up to some desired accuracy and get good rational approximations. It's not a very useful exercise on a number that isn't known to have any nice algebraic properties.

Re: x - cos(x) = 0

Posted: Tue Feb 03, 2009 4:55 pm UTC
by bray
t0rajir0u wrote:Why? With enough digits it's trivial to compute the continued fraction representation of the Dottie number up to some desired accuracy and get good rational approximations. It's not a very useful exercise on a number that isn't known to have any nice algebraic properties.


Because it's there. And, yet again, the point was to get something by hand ab initio. Obviously if you start with a decimal approximation you can do better and, seriously, it's more useful of an exercise to take one rational approximation (the decimal one) and come up with another one? (Using a generic algorithm that has nothing to do with the problem at hand, one might add.) Come on.

Re: x - cos(x) = 0

Posted: Tue Feb 03, 2009 7:47 pm UTC
by Cosmologicon
I got [imath](\sqrt{\pi+3}-1)/2[/imath] completely by hand in about 10 lines - no computers used at all. It's good to within 0.004% (though I used a calculator to find that fact). Beat that!

EDIT: Okay here's the derivation.
Spoiler:
[math]x^2 = \cos^2{x} = \frac{1}{2}(1 + \cos{2x}) = \frac{1}{2}(1 + \sin(\pi/2 - 2x)) = \frac{1}{2}(1 + \pi/2 - 2x)[/math]where the last step is an approximation. Then you solve the quadratic.

Re: x - cos(x) = 0

Posted: Tue Feb 03, 2009 8:17 pm UTC
by Ended
[math]\pi / 4 - (1 + \sqrt{2}) + \sqrt{5 + 2\sqrt{2} - \pi / \sqrt{2}}[/math]
Good to within 0.001%! Although yours is much tidier, Cosmologicon.

Spoiler:
Write x = pi/4 + y. It's pretty clear (from considering the graphs) that y will be small. Expand cos(pi/4 + y) = pi/4 + y, Taylor series to 2nd order and solve the quadratic.


edit: the Mathworld page gives the approximation [imath]{(\pi/160)}^{1/13}[/imath], good to 0.00003%. Nice.

Re: x - cos(x) = 0

Posted: Thu Feb 05, 2009 1:16 am UTC
by cspirou
t0rajir0u wrote:The fact that it's iterative says nothing about whether it has any attractors. There are plenty of examples of iterative mappings with no attractors (in [imath]\mathbb{R}[/imath]), for example [imath]f(x) = x^2 + 1[/imath].


First of all it only intersects at one point and that point is an attractor. Second of all the iterations is literally what is happening when you keep putting it in cosine over and over. That's why I brought it up.