1

My apologies if this already has an answer, I've spent some time looking but haven't found anything that (to me) looked directly applicable.

I have a set of parametric equations describing a periodic curve on an interval, say, $0\le t\le 4\pi$: $$ x=t+\sin{(t)}\\ y=-\cos{(t)} $$ This curve looks like a function, so I feel like I ought to be able to come up with a Cartesian form $y=f(x)$ for which each (x,y) coordinate pair would be identical to the corresponding parametric coordinate pair.

I've tried solving and substituting, but I only know how to solve the $y$ parametric for $t$: $$y=-\cos{(t)}$$ becomes $$ t=\arccos{(-y)}$$ And so I treat can $y$ as the independent variable and do: $$ x=\arccos{(-y)} + \sin{(\arccos{(-y)})} $$ with $y$ defined only over the interval $-1\le y \le 1$ which limits me to a single half of one wavelength, and repeated concatenating of this is not trivial because the interval between each successive x-value is not the same. I don't know how to solve the $x$ parametric, maybe someone who is a whiz with trig identities can offer a path.

I can use the x and y parametric values to create an interpolation programatically, but this is cumbersome and problematic for reasons beyond scope, etc.

Here's a plot (code at the bottom, in Python) of a parametric and interpolated version of this curve:

parametric equations: x=a+sin(a); y=-cos(t); 0<t<4pi

My motivation is to be able to treat multiple wavelengths/amplitudes/phases as discretized waveforms to be manipulated together, with identical sample rate, syncronous sampling, etc. in simulating various physical effects (sample-wise addition, etc.). Also, not being able to figure this out bugs me. I would think this would be a simple additional term, as in $y=-cos{(x + [some\ expression])}$ over $x$ in some interval, but I can't come up with this additional expression. Maybe this is a case requiring implicitization as mentioned here?

Python code I used for the plot:

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np from scipy.interpolate import interp1d import matplotlib from matplotlib import pyplot as plt from matplotlib.ticker import AutoMinorLocator as AML matplotlib.use('TKAgg')

cyc = 3.0 n_per_cyc = 20

def xy_from_a(a): x = a + np.sin(a) y = -np.cos(a) return x, y

def interp_param_to_xy(a, x, y): interpolator = interp1d(x, y) x_interpolated = np.array(a) y_interpolated = interpolator(x_interpolated) return x_interpolated, y_interpolated

def plot( xmin=None, xmax=None, ymin=None, ymax=None, xunits=None, yunits=None, title=None, square=True, ): plt.rcParams['legend.fontsize'] = 10 plt.rcParams['figure.figsize'] = [18, 4] plt.figure() ax = plt.gca() ax.set_xlabel('x (radians)', fontsize=16) ax.set_ylabel('y', fontsize=16)

ax.plot(x_neg_cos, y_neg_cos,
    label='neg_cos', color='#000000',
    linestyle=':',
    marker='.', markersize=5.0,
    linewidth=0.5)
ax.plot(x_parametric, y_parametric,
    label='parametric', color='#009f00',
    linestyle='-',
    marker='.', markersize=8.0,
    linewidth=1.0)
ax.plot(x_interpolated, y_interpolated,
    label='interpolated', color='#ff0000',
    linestyle=':',
    marker='.', markersize=5.0,
    linewidth=1.0)

plt.legend(loc='best')
minorLocator1X = AML()
minorLocator1Y = AML()
ax.xaxis.set_minor_locator(minorLocator1X)
ax.yaxis.set_minor_locator(minorLocator1Y)
ax.tick_params(which='major', width=2, length=7)
ax.tick_params(which='minor', width=2, length=4)
ax.grid(visible=True, which='major', color='gray', linestyle='-')
ax.grid(visible=True, which='minor', color='gray', linestyle=':')

if title is not None:
    plt.title(title, fontsize=20)

if xunits is not None:
    ax.set_xlabel(xunits, fontsize=16)
if yunits is not None:
    ax.set_ylabel(yunits, fontsize=16)

if xmin is not None:
    ax.axis(xmin=xmin)
if xmax is not None:
    ax.axis(xmax=xmax)
if ymin is not None:
    ax.axis(ymin=ymin)
if ymax is not None:
    ax.axis(ymax=ymax)

if square:
    ax.set_aspect('equal', adjustable='box')

plt.tight_layout()

plt.show()



print('x = θ + sin(θ)') print('y = -cos(θ)')

n = int(round(n_per_cyc * cyc, 0)) t = np.linspace(0.0, 2.0 * np.pi * cyc, num=n + 1, endpoint=True)

x_neg_cos = t[:n] y_neg_cos = -np.cos(x_neg_cos)

x_parametric, y_parametric = xy_from_a(t)

t = t[:n]

x_interpolated, y_interpolated = interp_param_to_xy(t, x_parametric, y_parametric)

x_parametric = x_parametric[:n] y_parametric = y_parametric[:n]

plot( xmin=0.0, xmax=np.pi / 2.0 * 8.0, square=True, )

EDIT:

Thanks @Gwen, with the help of your comment/answer I succeeded in finding several trig identities that let me follow you to your answer: $$y=-\cos(x\pm\sqrt{1-y^2})$$ It may be possible, using further trig identities or some other means, to solve for y, but if so, I can't figure it out. So, I solved for x, which gives me: $$x=\arccos(-y)\pm\sqrt{1-y^2}$$ But of course this, even treated piecewise, leaves me with the same problem as before, in that x is not the independent variable. (Also, in a programmatic context like Python, x values for both halves come out positive because of how arccos is defined to output in [0, $\pi$].)

Is there a way to solve for y, or some other way to rearrange this so that, whether piecewise or not, y is calculated from x, enabling me to programmatically assign x (piecewise if necessary) over whatever domain and granularity I need?

SteveP
  • 11
  • You can simplify$$\sin(\arccos(-y))=\sin\left(\frac\pi2+\arcsin y\right)=\cos(\arcsin y) = \sqrt{1-y^2}$$but the end result is a transcendental equation in $y$. – user170231 May 23 '24 at 23:53
  • Sadly this is still defined within that [-1,1] range. @user170231 I have a question regarding inv trigo indetities. Why isn't $$\cos(\arcsin y)= ±\sqrt{1-y^2}$$ – Gwen May 24 '24 at 01:24
  • @Gwen $\arcsin y\in\left[-\pi/2,\pi/2\right]\implies\cos(\arcsin y)\ge0$ – user170231 May 24 '24 at 03:37

1 Answers1

1

$$x^2+y^2=t^2+1+2t\sin t=1+2tx-t^2$$ $$\implies y^2=1-(x-t)^2\implies t=x\mp\sqrt{1-y^2}$$

So $$y=-\cos\bigg(x\mp \sqrt{1-y^2}\bigg)$$ For this we need a piecewise function. $$y=\begin{cases} \cos(x+\sqrt{1-y^2}) & (2n-1)π≤x≤2nπ\\ \cos(x-\sqrt{1-y^2}) & 2nπ≤x≤(2n+1)π\\ \end{cases}\\n\in\mathbb{Z}$$

You can check this graph in desmos. This wriggles through both the functions like a worm, if you set $n$ as rational numbers.

Gwen
  • 3,910
  • 6
  • 19
  • OK @Gwen, I think I see how this works, this is good. I can deal with piecewise. Unfortunately, for my purposes, I'm using discrete waveforms, so I have a list of values for x to plug into the equations. So, I need to solve for y. I can easily solve for x in the above, and calculate x as a function of y, but then the x values are not evenly spaced, of course. So I'm still a little stuck... But thanks! – SteveP May 24 '24 at 23:20
  • The full form of this very simple model includes terms for amplitude and wavelength ($\lambda$): $x=(\lambda t/2\pi) + (\sin(t)*amplitude)$ and $y=-\cos(\lambda t/2\pi)$ – SteveP May 24 '24 at 23:31