0
$\begingroup$

I am trying to find a simple sine-wave based function with a period of 1 where the crest is at h and trough at l, where l,h are reals and l < h. The function doesn't have to be continuous. The closest I've come so far is using the simple following piece-wise function:

$$ f=\left\{x\le h:\left(h-l\right)^{-1}\left(x-l\right),\ x>h:-\left(1+l-h\right)^{-1}\left(x-1-l\right)\right\} $$

as an input to the following:

$$ \sin\left(\pi f-0.5\pi\right) $$

This at least has the trough at l and crest at h for the interval [0, 1] but falls apart beyond that since the slope is only changing correctly in that first interval but I'm not sure how to make the slope change periodically as well (I didn't have much success with modulo). What am I missing or is there another, easier way to do this?

$\endgroup$

1 Answer 1

0
$\begingroup$

Obviously, you can't have both a constant frequency and continuous endpoints unless you have a real sine wave. There are a few different ways, depending on what you mean by "sine-wave based" function.

One of the "easiest", since you specified it doesn't have to be continuous, is to simply linearly interpolate the angle such that $\theta(l)=-\frac{\pi}{2}$, $\theta(h)=\frac{\pi}{2}$. You want a line with slope $\pi/(h-l)$ crossing $0$ at $(h+l)/2$: $$f(t)=\sin\left(\frac{\pi}{h-l}\left((t\mod 1)-\frac{h+l}{2}\right)\right)$$ This will have period 1 by force, and is discontinuous at integers (the phase jumps).

The second function you provided pieces together two sine waves of different frequencies, so that you get continuity (if you did it correctly).

To get the slope to change periodically, you may also consider other types of phase transfer functions $\theta$ (you called it $f$), where you're looking at $\sin(\theta(t))$. Effectively, the instantaneous frequency (and hence the slope) at time $t$ will be $\theta'(t)$, which you can control.

Again, the only real constraints you have is that $\theta(l)=-\frac{\pi}{2}$ and $\theta(h)=\frac{\pi}{2}$, and you can play around depending on what properties you want. For example, $\theta(0)-\theta(1)=0\mod2\pi$ gives continuity at integers.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .