20

One thing, I'm not a mathematician so please be patient. I am still in Algebra II Trig. Leading with that, why does

$$ x_0 = \sin 1, \space x_1 = x_0 + \sin x_0, \space x_2 = x_1 + \sin x_1 ... $$ and after a while, $$ x = \pi $$

I know this to be true because I have evaluated this on my TI-84 and more deeply evaluated it with this program I made: https://repl.it/@RobertoBean/Pi-Evaluator To $100000$ Iterations (which I believe is enough)

So what's the math behind it? Why does adding $\sin 1$ in this manner produce $\pi$? Why doesn't doing the same thing using $100$ produce $\pi$? For example, $$\sin(1) = 0.841470...,\space \sin(1) + \sin(0.8414...), \sin(1) + \sin(0.841470...) + \sin(1.587095126...),\space ... $$ $$ = \pi$$

My question is different from the mentioned because my function is not taking the sin of a sin consecutively, but is this following function: $f(x) = x + \sin x$ and is not $f(x) = \sin x$ and therefore can exhibit different properties I need explained.

  • 4
    Does it? Where did you find this? – egreg Mar 07 '18 at 23:38
  • 3
    $\sin\left(1\right)+\sin\left(\sin1\right)+\sin\left(\sin\left(\sin1\right)\right)+\sin\left(\sin\left(\sin\left(\sin\left(1\right)\right)\right)\right)+\sin\left(\sin\left(\sin\left(\sin\left(\sin1\right)\right)\right)\right)>pi$ – supersmarty1234 Mar 07 '18 at 23:39
  • @supersmarty visit the link – Corpus Shmorpus Mar 07 '18 at 23:41
  • I never knew $\pi \approx 97.389372261283597254077903926372528076171875$, that is what it output. –  Mar 07 '18 at 23:42
  • @idk Sorry, I rewrote the question. Did not convey what I was trying to say. Remember, only in Trig – Corpus Shmorpus Mar 07 '18 at 23:45
  • $$\sin(1) = 0.841470...,\space \sin(1) + \sin(0.8414...), \sin(1) + \sin(0.841470...) + \sin(1.587095126...),\space ... $$ $$ = \pi$$ – Corpus Shmorpus Mar 07 '18 at 23:46
  • 5
    $x = x + \sin x \iff \sin x = 0$. – amWhy Mar 07 '18 at 23:53
  • @idk also it output that because I made the starting value 100 and forgot to change it. – Corpus Shmorpus Mar 07 '18 at 23:54
  • 4
    You are iteratively evaluating the map $x \mapsto x + \sin(x)$, and discovering that this map has a fixed point (i.e. there is some value of $x$ such that $x = x + \sin(x)$). There are some thorny issues of convergence, but assuming that everything plays nice, you get $$ x = x + \sin(x) \implies 0 = \sin(x) \implies x \in { \pi k : k\in\mathbb{Z} }.$$ – Xander Henderson Mar 07 '18 at 23:54
  • 1
    It is true for the recurrence $$ \left{ \matrix{ x_{,0} = \sin (1) \hfill \cr x_{,n} = x_{,n - 1} + \sin (x_{,n - 1} ) \hfill \cr} \right. $$ so rewrite your post accordingly – G Cab Mar 07 '18 at 23:56
  • @Xander what does that mean, or where can I go to figure out what that means? – Corpus Shmorpus Mar 07 '18 at 23:56
  • @GCab yes that was exactly what I was trying to ask, as long as the subscript n means where we are in the sequence, or more better put, how much we have added – Corpus Shmorpus Mar 08 '18 at 00:10
  • @GCab However, $c=1$ and only one. Attempt the problem with 100 – Corpus Shmorpus Mar 08 '18 at 00:12
  • @coderboy: If $x_1\ne 0$, then $(x_n)$ converges to either $\pi$ or $-\pi$. – quasi Mar 08 '18 at 00:16
  • 1
    You can have a look at Fixed-point iteration and maybe try to draw corresponding cobweb plot. Here are some examples for other functions. – Martin Sleziak Mar 08 '18 at 00:20
  • @quasi I think if $(x_n) \to \pm \pi$ then for $X_1 := x_1 + 2\pi m$ then $(X_n) \to \pm \pi + 2\pi m$. – Ben Mar 08 '18 at 00:22
  • @Ben: Oops, you're right. – quasi Mar 08 '18 at 00:25
  • 1
    The contraction mapping principle asserts that if there is some $c \in (0,1)$ such that $|f(x) - f(y)| < c |x-y|$ on some compact domain, then the mapping $x \mapsto f(x)$ has a unique fixed point. We would like to apply this to the mapping $x \mapsto x + \sin(x)$. Unfortunately, this is not a contraction mapping on all of $\mathbb{R}$. Indeed, it has many fixed points, each corresponding to a different domain where it is a contraction mapping. This is somewhat illuminating. – Xander Henderson Mar 08 '18 at 00:26
  • 3
    One drawback, @quasi, is that your edit masked the fact that the OP is unfamiliar with the notions of sequences and convergence (that would be an important information in answering this question IMO). –  Mar 08 '18 at 00:43
  • @Coderboy I guess you can get $x$ closed to $\pi$, but probably not $x = \pi$. –  Mar 08 '18 at 00:44
  • @John Maybe if the function were iterated an $\infty$ amount of times. Not sure. – Corpus Shmorpus Mar 08 '18 at 00:47
  • @John Ma: At the algebra-2 level, the student is likely to have been introduced to sequences such as the Fibonacci sequence. As far as convergence, geometric series and the related notion of convergence is usually introduced informally at that level. – quasi Mar 08 '18 at 00:47
  • @Coderboy: I was trying to help, but the intention of your post is now clear anyway, so no big deal. – quasi Mar 08 '18 at 00:49
  • @Coderboy: The main area of math that deals with questions like yours is called "Dynamical Systems". Recommended prerequisites are Precalculus, Calculus, Linear Algebra, and Differential Equations. – quasi Mar 08 '18 at 00:52
  • @quasi Where can I go to learn enough to understand answers to my question? – Corpus Shmorpus Mar 08 '18 at 00:53
  • @Coderboy: I recommend waiting a bit (see my prior comment). – quasi Mar 08 '18 at 00:54
  • @quasi That's not what I was hoping for. I will come back and look at the answers to this when I am older, however. – Corpus Shmorpus Mar 08 '18 at 00:55
  • Do you understand the answer by G Cab (The horizontal and vertical arrows in particular)? In some sense that is already a very good intuition. @Coderboy –  Mar 08 '18 at 00:58
  • 1
    @John Yes. I think it means that if I have a number that falls between $number * \pi$ and $(number + 2) * \pi$ the result will be $(number + 1) * \pi$ So 50 will be $15\pi$ I think the arrows mean there is an attractive force towards those places, hence the name attractor? Almost like the numbers start to change round those points to try and be closer to $n\pi$. Am I right? – Corpus Shmorpus Mar 08 '18 at 01:02
  • Just realized I can do the same thing with cos and multiply the final result by 2 and get $\pi$. – Corpus Shmorpus Mar 08 '18 at 01:36
  • @supersmarty1234: You applied the wrong formula. x1 is sin(sin(1)) + sin(1), x2 is sin(sin(1)) + sin(1) + sin(sin(sin(1)) + sin(1)) and x3 is sin(sin(sin(1)) + sin(1) + sin(sin(sin(1)) + sin(1))) + sin(sin(1)) + sin(1) + sin(sin(sin(1)) + sin(1)). Sadly, it isn't as easy as your proposal. – Eric Duminil Mar 08 '18 at 21:49
  • Why is this question so popular? I thought it was just a casual math question, is there something else I'm missing? – Corpus Shmorpus Mar 08 '18 at 23:21
  • @Coderboy: It's a simple question (and therefore easy to understand, even for non-experts) with several interesting and nontrivial answers. Those often tend to get a lot of upvotes. Also, with several quick and popular answers, it may have ended up on Hot Network Questions list for a while. – Ilmari Karonen Mar 10 '18 at 21:15

3 Answers3

33

So the sequence is $$ \begin{cases} x_{0} = c & \\ x_{n} = x_{n - 1} + \sin (x_{n - 1} ) & \end{cases} $$

and this is what is going to happen. sin@sin-2

The sketch shows that for $0< x_0 < 2\pi$ the recurrence will lead to $\pi$,
for $2\pi< x_0 < 4\pi$ it will lead to $3\pi$, etc.

That means that, among all the solutions $x=n\pi$ to $x=x+\sin(x)$, the actual attractor points are those at $(2n+1)\pi$, while the $2n\pi$ points are unstable.

G Cab
  • 35,272
  • Is this why when I run the function with 100 it returns $\approx 97.3893722612$? – Corpus Shmorpus Mar 08 '18 at 00:57
  • @Coderboy: yes $$ \eqalign{ & x_{,0} = 100\quad \Rightarrow \quad \left\lfloor {{{100} \over {2\pi }}} \right\rfloor = 15,\quad 100\bmod \left( {2\pi } \right) \approx 0.9\quad \Rightarrow \cr & \Rightarrow \quad x_{,\infty } = 31;\pi \approx 97.38 \cr} $$ – G Cab Mar 08 '18 at 01:08
  • so that means 100 falls between $30\pi$ and $32\pi$? I'm very intrigued. – Corpus Shmorpus Mar 08 '18 at 01:09
  • 1
    exactly, but shall be strictly greater or lower: if you start with precisely $30\pi$ you will remain there (theoretically, numerically the computation error might you drift around or out). – G Cab Mar 08 '18 at 01:14
  • I know that that is true because when I call the int.binary() method from the integer class in python it doesn't equal what I intend it to when doing math things. Basically, computers suck at doing math with decimals – Corpus Shmorpus Mar 08 '18 at 01:17
  • @Coderboy: yes computers are very powerful, but can be tremendously misleading if not "handled" with much care! – G Cab Mar 08 '18 at 01:22
  • @Coderboy: considering previous comment, it would be interesting to know which is the minimum number of iterations required to get a given accuracy. – G Cab Mar 08 '18 at 01:42
  • @G Cab to get 50 decimal places matching the given value of PI, you need 5 iterations – Corpus Shmorpus Mar 08 '18 at 01:44
  • 3
    @Coderboy The reason for the fast convergence to $x_\infty=31\pi$ that you observed, is that, when $x\to x_\infty$, $f(x)-x_\infty\sim\frac16(x-x_\infty)^3$. Hence, after a while, the number of correct decimals is (roughly) multiplied by $3$ at each iteration. – Did Mar 08 '18 at 06:52
  • @Did: thanks , I was curious to know an estimate of convergence speed – G Cab Mar 08 '18 at 09:34
10

It seems the OP has a hard time understanding the answers referring to fixed point iterations - I do too. Here follows a more intuitive and practical way to visualise what OP's formula is doing is by using the arc length of the arcs on the unit circle.

Your angle measured in radians is equal to the arc length of a segment of that angle - let's call it $ø$.

$sin(ø)$ gives you the y-coordinate (distance from the x-axis) of the end of that arc with it's centre at the origin.

In your next step you are creating a new arc by lengthening your arc by $sin(ø)$ and then you measure the distance from the x-axis for the end of your new arc and you keep repeating this procedure.

The measured distance from the x-axis will always be smaller than the length needed to lengthen your arc to $π$ but it keeps getting closer.

The illustration below explains it graphically and it's also easy to see from this why it converges so quickly:

enter image description here

Edit:

The arc length of the remainder of the half circle not covered by your arc is $π-ø$. By inspection, you can prove that $sin(ø)$ will always be smaller than that arc length (except when $ø=π$), thus, continuously adding $sin(ø)$ and adjusting ø to this new value will never exceed $π$.

Similarly you can see that for any value less than $π$, the result will increase, until you reach pi (which will happen at infinity).

ChP
  • 216
4

You are iterating the function $$f(x)= x+ \sin(x).$$

When you iterate a function and the function has a fixed point which happens to be an attractor, the sequence of iterates approaches that attractor.

In the case of $$f(x) = x+\sin(x)$$ the fixed point is found by $f(x)=x$ which is $$x+\sin(x)=x$$

Thus $\sin(x)=0$ which implies $x=\pi$ is the attractor.

  • so because $\sin \pi = 0$, that means that x is $\pi$? – Corpus Shmorpus Mar 08 '18 at 00:36
  • 8
    This is not entirely correct. What do you mean by "happens to be an attractor"? How do you know that this map has an attractor? Is the attractor unique? And, most importantly to the original questioner (it seems), why does iterating with $x_0 = 1$ give you $\pi$, while $x_0 = 100$ gives something else? – Xander Henderson Mar 08 '18 at 00:36
  • @Xander Oh yeah that's right. $f(x) = x + \sin x$ converges differently if $x_0 \ne 1$. I'm already learning :) – Corpus Shmorpus Mar 08 '18 at 00:38
  • The x_0=1 is in the basin of attraction of the fixed point $x=\pi$ $x_0=100$ is probably in the basin of attraction of another attractor. The attractors do not have to be unique. For example if you apply Newton's Method to f(x)= sin(x), depending on your initial condition you get different attractors. – Mohammad Riazi-Kermani Mar 08 '18 at 00:41