x - cos(x) = 0

For the discussion of math. Duh.

Moderators: gmalivuk, Moderators General, Prelates

tricky77puzzle
Will take "No Tresspassing Signs" for 500
Posts: 488
Joined: Thu Feb 28, 2008 11:02 pm UTC

x - cos(x) = 0

Postby tricky77puzzle » Thu Jan 15, 2009 12:40 am UTC

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.)

++$_
Mo' Money
Posts: 2370
Joined: Thu Nov 01, 2007 4:06 am UTC

Re: x - cos(x) = 0

Postby ++$_ » Thu Jan 15, 2009 12:49 am UTC

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.)

Ended
Posts: 1459
Joined: Fri Apr 20, 2007 3:27 pm UTC
Location: The Tower of Flints. (Also known as: England.)

Re: x - cos(x) = 0

Postby Ended » Thu Jan 15, 2009 1:01 am UTC

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." :|
Generally I try to make myself do things I instinctively avoid, in case they are awesome.
-dubsola

User avatar
t0rajir0u
Posts: 1178
Joined: Wed Apr 16, 2008 12:52 am UTC
Location: Cambridge, MA
Contact:

Re: x - cos(x) = 0

Postby t0rajir0u » Thu Jan 15, 2009 1:13 am UTC

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).

User avatar
NathanielJ
Posts: 882
Joined: Sun Jan 13, 2008 9:04 pm UTC

Re: x - cos(x) = 0

Postby NathanielJ » Thu Jan 15, 2009 1:34 am UTC

Here's a thread with some discussion on the Dottie number:

http://forums.xkcd.com/viewtopic.php?f=17&t=23066&p=687416
Homepage: http://www.njohnston.ca
Conway's Game of Life: http://www.conwaylife.com

cspirou
Posts: 147
Joined: Wed Jun 11, 2008 4:09 pm UTC

Re: x - cos(x) = 0

Postby cspirou » Thu Jan 15, 2009 5:28 am UTC

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.

User avatar
t0rajir0u
Posts: 1178
Joined: Wed Apr 16, 2008 12:52 am UTC
Location: Cambridge, MA
Contact:

Re: x - cos(x) = 0

Postby t0rajir0u » Thu Jan 15, 2009 5:33 am UTC

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].

Rentsy
Posts: 154
Joined: Tue Dec 02, 2008 4:13 am UTC

Re: x - cos(x) = 0

Postby Rentsy » Thu Jan 15, 2009 6:05 am UTC

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...

User avatar
Cosmologicon
Posts: 1806
Joined: Sat Nov 25, 2006 9:47 am UTC
Location: Cambridge MA USA
Contact:

Re: x - cos(x) = 0

Postby Cosmologicon » Thu Jan 15, 2009 10:55 am UTC

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.

Ended
Posts: 1459
Joined: Fri Apr 20, 2007 3:27 pm UTC
Location: The Tower of Flints. (Also known as: England.)

Re: x - cos(x) = 0

Postby Ended » Thu Jan 15, 2009 7:00 pm UTC

Cosmologicon wrote:That's why the mysterious number 0 is called the Cosmologicon number.

The Mathematics Council might not be too happy with that.
Generally I try to make myself do things I instinctively avoid, in case they are awesome.
-dubsola

tricky77puzzle
Will take "No Tresspassing Signs" for 500
Posts: 488
Joined: Thu Feb 28, 2008 11:02 pm UTC

Re: x - cos(x) = 0

Postby tricky77puzzle » Thu Jan 15, 2009 11:21 pm UTC

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.

User avatar
t0rajir0u
Posts: 1178
Joined: Wed Apr 16, 2008 12:52 am UTC
Location: Cambridge, MA
Contact:

Re: x - cos(x) = 0

Postby t0rajir0u » Fri Jan 16, 2009 5:57 am UTC

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.

User avatar
Beacons!
Posts: 213
Joined: Thu May 29, 2008 2:17 pm UTC
Location: The Grand Unifying Intermahweb

Re: x - cos(x) = 0

Postby Beacons! » Wed Jan 21, 2009 12:22 pm UTC

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.
"Woof!", explained the dog

cspirou
Posts: 147
Joined: Wed Jun 11, 2008 4:09 pm UTC

Re: x - cos(x) = 0

Postby cspirou » Mon Jan 26, 2009 6:52 am UTC

It gets attracted to that point because it's an iterative mapping.

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

User avatar
t0rajir0u
Posts: 1178
Joined: Wed Apr 16, 2008 12:52 am UTC
Location: Cambridge, MA
Contact:

Re: x - cos(x) = 0

Postby t0rajir0u » Mon Jan 26, 2009 7:05 pm UTC

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].

User avatar
A_of_s_t
Posts: 180
Joined: Tue Aug 26, 2008 5:10 am UTC
Contact:

Re: x - cos(x) = 0

Postby A_of_s_t » Tue Jan 27, 2009 1:51 pm UTC

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 :/
Check out my web interzones powered by Web 3.0 technology running on Mozzarella Foxfire:
Spoiler:
Image
Image
Image

User avatar
Cosmologicon
Posts: 1806
Joined: Sat Nov 25, 2006 9:47 am UTC
Location: Cambridge MA USA
Contact:

Re: x - cos(x) = 0

Postby Cosmologicon » Tue Jan 27, 2009 2:09 pm UTC

You can also just do n2 = cos(n1). No calculus needed.

User avatar
PM 2Ring
Posts: 3715
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Sydney, Australia

Re: x - cos(x) = 0

Postby PM 2Ring » Tue Jan 27, 2009 3:56 pm UTC

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. :)

User avatar
jestingrabbit
Factoids are just Datas that haven't grown up yet
Posts: 5967
Joined: Tue Nov 28, 2006 9:50 pm UTC
Location: Sydney

Re: x - cos(x) = 0

Postby jestingrabbit » Tue Jan 27, 2009 4:14 pm UTC

PM 2Ring wrote:Prof. Dottie


Fixed and I think that's probably part of why the name is what it is.
ameretrifle wrote:Magic space feudalism is therefore a viable idea.

User avatar
PM 2Ring
Posts: 3715
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Sydney, Australia

Re: x - cos(x) = 0

Postby PM 2Ring » Tue Jan 27, 2009 4:37 pm UTC

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.

bray
Posts: 67
Joined: Wed Aug 15, 2007 4:17 pm UTC

Re: x - cos(x) = 0

Postby bray » Tue Jan 27, 2009 9:35 pm UTC

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.

User avatar
NathanielJ
Posts: 882
Joined: Sun Jan 13, 2008 9:04 pm UTC

Re: x - cos(x) = 0

Postby NathanielJ » Tue Jan 27, 2009 9:59 pm UTC

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.
Homepage: http://www.njohnston.ca
Conway's Game of Life: http://www.conwaylife.com

bray
Posts: 67
Joined: Wed Aug 15, 2007 4:17 pm UTC

Re: x - cos(x) = 0

Postby bray » Tue Jan 27, 2009 10:28 pm UTC

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.

User avatar
jestingrabbit
Factoids are just Datas that haven't grown up yet
Posts: 5967
Joined: Tue Nov 28, 2006 9:50 pm UTC
Location: Sydney

Re: x - cos(x) = 0

Postby jestingrabbit » Wed Jan 28, 2009 12:04 am UTC

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.
ameretrifle wrote:Magic space feudalism is therefore a viable idea.

User avatar
0xDEADBEEF
Posts: 284
Joined: Wed Jan 30, 2008 6:05 am UTC
Location: Austin, TX
Contact:

Re: x - cos(x) = 0

Postby 0xDEADBEEF » Wed Jan 28, 2009 12:14 am UTC

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

User avatar
NathanielJ
Posts: 882
Joined: Sun Jan 13, 2008 9:04 pm UTC

Re: x - cos(x) = 0

Postby NathanielJ » Wed Jan 28, 2009 12:47 am UTC

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.
Homepage: http://www.njohnston.ca
Conway's Game of Life: http://www.conwaylife.com

User avatar
Macbi
Posts: 941
Joined: Mon Apr 09, 2007 8:32 am UTC
Location: UKvia

Re: x - cos(x) = 0

Postby Macbi » Wed Jan 28, 2009 7:43 am UTC

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%!
    Indigo is a lie.
    Which idiot decided that websites can't go within 4cm of the edge of the screen?
    There should be a null word, for the question "Is anybody there?" and to see if microphones are on.

User avatar
qinwamascot
Posts: 688
Joined: Sat Oct 04, 2008 8:50 am UTC
Location: Oklahoma, U.S.A.

Re: x - cos(x) = 0

Postby qinwamascot » Wed Jan 28, 2009 8:21 am UTC

7093/9597 is much closer. I'm going with that for now.
Quiznos>Subway

User avatar
jaap
Posts: 2094
Joined: Fri Jul 06, 2007 7:06 am UTC
Contact:

Re: x - cos(x) = 0

Postby jaap » Wed Jan 28, 2009 9:13 am UTC

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.

uewebawo
Posts: 11
Joined: Tue Jan 08, 2008 5:27 am UTC
Contact:

Re: x - cos(x) = 0

Postby uewebawo » Sat Jan 31, 2009 10:28 am UTC

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.
Now I know where baby tables come from!

Come see us over at Castle Arcanum

User avatar
Macbi
Posts: 941
Joined: Mon Apr 09, 2007 8:32 am UTC
Location: UKvia

Re: x - cos(x) = 0

Postby Macbi » Sat Jan 31, 2009 10:58 am UTC

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?
    Indigo is a lie.
    Which idiot decided that websites can't go within 4cm of the edge of the screen?
    There should be a null word, for the question "Is anybody there?" and to see if microphones are on.

bray
Posts: 67
Joined: Wed Aug 15, 2007 4:17 pm UTC

Re: x - cos(x) = 0

Postby bray » Tue Feb 03, 2009 1:04 am UTC

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.

User avatar
t0rajir0u
Posts: 1178
Joined: Wed Apr 16, 2008 12:52 am UTC
Location: Cambridge, MA
Contact:

Re: x - cos(x) = 0

Postby t0rajir0u » Tue Feb 03, 2009 4:44 pm UTC

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.

bray
Posts: 67
Joined: Wed Aug 15, 2007 4:17 pm UTC

Re: x - cos(x) = 0

Postby bray » Tue Feb 03, 2009 4:55 pm UTC

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.

User avatar
Cosmologicon
Posts: 1806
Joined: Sat Nov 25, 2006 9:47 am UTC
Location: Cambridge MA USA
Contact:

Re: x - cos(x) = 0

Postby Cosmologicon » Tue Feb 03, 2009 7:47 pm UTC

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.

Ended
Posts: 1459
Joined: Fri Apr 20, 2007 3:27 pm UTC
Location: The Tower of Flints. (Also known as: England.)

Re: x - cos(x) = 0

Postby Ended » Tue Feb 03, 2009 8:17 pm UTC

[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.
Generally I try to make myself do things I instinctively avoid, in case they are awesome.
-dubsola

cspirou
Posts: 147
Joined: Wed Jun 11, 2008 4:09 pm UTC

Re: x - cos(x) = 0

Postby cspirou » Thu Feb 05, 2009 1:16 am UTC

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.


Return to “Mathematics”

Who is online

Users browsing this forum: No registered users and 10 guests