Solve for y in sin(y) = cos(y) using a fixed point procedure

451 Views Asked by At

I'm reading an programming book that uses a lot of math equations and formulas as coding examples. In one lesson, it demonstrates finding the fixed point for $\sin(x) + \cos(x)$ by repeatedly calling the same function on the function's result until a tolerable answer is found.

$$ f(x) = \cos(x) + \sin(x) $$ $$ f(f(f(...f(1)))) \iff 1.2587282 \iff \cos(1.2587282) + \sin(1.2587282) $$

When I plot $y = \sin(x) + \cos(x)$ that is correct.

Another beautiful example was given to demonstrate that the golden ratio $φ$ is a fixed point of the translation

$$ f(x) = 1 + 1/x $$

$$ f(f(f(...f(x)))) \iff 1.618033988 \iff φ $$

My brain was wandering and I was curious to write my own equation and solve it, but I'm not particularly good at math beyond basic geometry/trigonometry so I got stuck.

I thought, "Ok, let's try to use the fixed point procedure to find the solution for $\sin(x) = \cos(x)$...". I ran into trouble when I tried creating the function for it.

Can $\sin(x) = \cos(x)$ be represented as a function that can be solved using the fixed point procedure above?

$$ g(x) = ... ??? $$ $$ g(g(g(...g(1)))) \iff ? \iff \sin(x) \iff \cos(x) $$

(Yes, I realize that there are an infinite number of fixed points for $\sin(x) = \cos(x)$ but I'm okay with just getting the pair one closest to zero.)

2

There are 2 best solutions below

3
On

$\sin x=\cos x \implies tan x=1\implies \tan x=\tan\dfrac{\pi}{4} \implies x=n\pi+\dfrac{\pi}{4}\\$ where $\\ n\in N$

1
On

A fixed point $x$ of a function $f$ is one such that $x=f(x)$.

If you want $\sin x = \cos x$, you could try $g_1(x)=\arcsin(\cos x)$ or $g_2(x)=\arccos(\sin x)$. This way, when you solve $x =\arcsin(\cos x)$ you end up with $\sin x = \cos x$ (similarly for the other).


Edit: Actually, having plotted $g_1$ and $g_2$, I realized that neither of them would converge under a fixed-point method (the quick/handwaving explanation is that "near" the fixed point, both $g_1$ and $g_2$ are perpendicular to the identity function).

Solving $\sin x=\cos x$ then would be better approached by a (perhaps more general) root-finding procedure on $g(x)=\sin x - \cos x$ instead of the fixed-point approach.