# how to get a nice "cosine looking" curve following the y=x direction?

My aim is to get a "cosine looking" curve rotated 45° counterclockwise.

When I graph : g(x)= x + cos(x) , I get a curve that has lost the nice and regular wavering of the ordinary f(x)= cos(x) curve.

Adding a coefficient does not work, but rather aggravates the change of form.

Is there a possible equation that would produce the curve I am aiming at?

Thanks for your help.

• – user856
Feb 22 '20 at 15:28
• $x-y = \cos(x+y)$. Feb 23 '20 at 1:05
• Here's a desmos rotator I wrote. Feb 23 '20 at 4:55
• @user76284-@mason- thanks a lot
– user655689
Feb 23 '20 at 12:58

Unfortunately, you can't with an explicit equation $$y=f(x)$$.

You need to resort to a parametric form such as

$$\begin{cases}x=t+\cos t,\\y=t-\cos t\end{cases},$$ obtained by rotation.

It is not possible to invert $$x=t+\cos t$$ analytically.

It is also possible to approximate this effect by assembling replicas and symmetries of the graph of a function like

$$y=\sqrt[n]{1-x^n}$$ computed in the interval $$[0,1]$$.

• out of curiosity I've just asked How do we know that is not possible to invert $x=t+\cos t$ analytically?
– uhoh
Feb 23 '20 at 1:50
• Apart from the slope it's periodic, perhaps Fourier analysis on x=t+cos(t),y=-cos(t) could yield f() such that y=x+f(x). Feb 23 '20 at 3:51
• @Jasen: Fourier analysis on a parametric curve is difficult. And due to the vertical slope, the Fourier series will converge very poorly, with strong Gibbs oscillations. Not a good idea.
– user65203
Feb 24 '20 at 7:36
• yes, I tried doing it numerically (using a speadsheet because I don't know how to drive Octave) I do see stong Gibbs phenomonon near the vertical it seems to converge slowly and takes about 14 terms before it even starts looking good this is possibly helped by the vertical part being a point rather than a line segment, Feb 24 '20 at 21:50

If you have the points of the form $$\bigl(x,\cos(x)\bigr)$$, you have the graph of the $$\cos$$ function. Now, multiply this by the matrix$$\begin{bmatrix}1&-1\\1&1\end{bmatrix}\left(=\sqrt2\begin{bmatrix}\cos\left(\frac\pi4\right)&-\sin\left(\frac\pi4\right)\\\sin\left(\frac\pi4\right)&\cos\left(\frac\pi4\right)\end{bmatrix}\right).$$In other words, consider the points of the form $$\bigl(x-\cos(x),x+\cos(x)\bigr)$$.

Wanting to consider the general case of roto-translation, writing in Wolfram Mathematica 12.0:

R[θ_] := {{Cos[θ], Sin[θ]}, {-Sin[θ], Cos[θ]}}
{xC, yC} = {2, 1};

xAxis = {xC, yC} + {t, 0}.R[θ];
yAxis = {xC, yC} + {0, t}.R[θ];
fun = {xC, yC} + {t, Cos[t]}.R[θ];

frames = Table[Magnify[ParametricPlot[{xAxis, yAxis, fun}, {t, -12, 12},
Epilog -> {Text[StringJoin["θ = ", ToString[TraditionalForm[θ]]],
{5, 9}], Black, PointSize[Large], Point[{xC, yC}]},
PlotRange -> {{-10, 10}, {-10, 10}},
PlotStyle -> {Blue, Red, Green}], 2],
{θ, 0, 2π, π/20}];

Export["image.gif", frames, "AnimationRepetitions" -> ∞, "DisplayDurations" -> 1];


we get:

As pointed out by user76284 in a comment, this can be done by writing an equation like $$y-x=\cos(x+y)$$. This form helps us to understand why we can't write down a closed-form equation for $$y$$ in terms of $$x$$, using only elementary functions. Such an equation would be a solution to a transcendental equation, which normally can't be expressed in this way. It also shows how we could probably write down a closed-form equation if we were willing to resort to special functions. For example, I would guess that you could write this function in terms of the Lambert W function or something similar.

• More generally, if $\theta$ is the desired angle of rotation, we have $u = \cos v$ where $u = x \cos \theta + y \sin \theta$ and $v = x \cos (\theta + \frac{\pi}{2}) + y \sin (\theta + \frac{\pi}{2})$. Feb 23 '20 at 2:20