How to find the sinusoidal function passing through 2 given points with known slopes?

499 Views Asked by At

I have 2 given points:

  • $y(0) = y_0$
  • $y(1) = y_1$

And I have the exact slopes/derivatives where the sinusoidal equation will intersect those points:

  • $y'(0) = y'_0$
  • $y'(1) = y'_1$

I understand sinusoidal functions can be written in either of these formats? :

  1. $y(x) = A \sin(Bx + C) + D$

  2. $y(x) = A \sin(Bx) + C \cos(Bx) + D$

    where $(A, B, C, D)$ are all the unknown variables that need to be calculated.

If I input $y_0$ and $y_1$ into the first format we get:

  • $y_0 = A \sin\bigl(B(0) + C\bigr) + D \implies A \sin(C) + D$
  • $y_1 = A \sin\bigl(B(1) + C\bigr) + D \implies A \sin(B + C) + D$

Alternatively, when plugged into the second format we get:

  • $y_0 = A \sin\bigl(B(0)\bigr) + C \cos\bigl(B(0)\bigr) + D \implies C + D$
  • $y_1 = A \sin\bigl(B(1)\bigr) + C \cos\bigl(B(1)\bigr) + D \implies A \sin(B) + C \cos(B) + D$

Now how can I plug the slopes $y'_0$ and $y'_1$ into these equations?...

I have read this very similar question here: How to fit a sinusoidal function through 2 points with known slopes? (the answer is very confusing) ... and I don't know how he came up with the following format:

  • $y'(x) = AB \cos(Bx) - CB \sin(Bx)$

... but using this new equation I now plug in $y'_0$ and $y'_1$ to get:

  • $y'_0 = AB \cos\bigl(B(0)\bigr) - CB \sin\bigl(B(0)\bigr) \implies AB$
  • $y'_1 = AB \cos\bigl(B(1)\bigr) - CB \sin\bigl(B(1)\bigr) \implies AB \cos(B) - CB \sin(B)$

Ok so, putting together all the info gathered thus far:

  • $y_0 = A \sin(C) + D$
  • $y_0 = C + D$
  • $y'_0 = AB$
  • $y_1 = A \sin(B + C) + D$
  • $y_1 = A \sin(B) + C \cos(B) + D$
  • $y'_1 = AB \cos(B) - CB \sin(B)$

This is as far as I've been able to come, how can I continue go about solving for $(A, B, C, D)$ to find the sinusoidal function passing through these 2 given points ($y_0$ and $y_1$) with given slopes ($y'_0$ and $y'_1$) at intersection?

From what I've read from that similar question, there are multiple solutions with varying $B$... and I too need the solution with the longest period (so I assume that is the smallest non-negative value for $B$ possible).

Please, I need to know this step by step and in detail. If I were to give you example parameters, here they are:

  • $y_0 = 4$
  • $y'_0 = 0.3$
  • $y_1 = 1$
  • $y'_1 = -0.1$
1

There are 1 best solutions below

2
On BEST ANSWER

You use two forms for $y(x)$ with symbols $A,B,C,D$ for the parameters. But the parameters are not respectively the same in the two formulas. This is confusing. Better use different symbols for each one of the two forms, or chose only one form and forget the second one. For example : $$y(x)=a\sin(wx)+b\cos(wx)+c$$ where the unknown parameters are $w,a,b,c$ $$y'(x)=aw\cos(wx)-bw\sin(wx)$$ Then put the given conditions into them. You got four equations: $$\begin{cases} y_0=b+c \\ y_1=a\sin(w)+b\cos(w)+c \\ y'_0=aw \\ y'_1=aw\cos(w)-bw\sin(w) \end{cases}$$ $c=y_0-b$ and $a=\frac{y'_0}{w}$ leads to : $$\begin{cases} y_1-y_0=\frac{y'_0}{w}\sin(w)+b\cos(w)-b \\ y'_1=y'_0\cos(w)-bw\sin(w) \end{cases}$$ where only two unknowns $w,b$ are remaining. $$\begin{cases} (y_1-y_0)w=y'_0\sin(w)+bw\left(\cos(w)-1\right) \\ y'_1=y'_0\cos(w)-bw\sin(w) \end{cases}$$ $b=\frac{-y'_1+y'_0\cos(w)}{w\sin(w)} \tag 3$ $$(y_1-y_0)w=y'_0\sin(w)+\frac{-y'_1+y'_0\cos(w)}{\sin(w)}\left(\cos(w)-1\right)$$ After simplification : $$w=\left(\frac{y'_1+y'_0}{y_1-y_0}\right)\frac{1-\cos(w)}{\sin(w)}$$ With $\begin{cases}C=\frac{y'_1+y'_0}{2(y_1-y_0)}\\w=2W\end{cases} \quad \quad\to\quad \frac{w}{2}=C\tan\left(\frac{w}{2}\right)\quad \quad\to\quad W=C\tan\left(W\right) \tag 4$

It is known that the roots of this kind of equation cannot expressed on a closed form with a finite number of elementary functions. So, we have to continue either with numerical solving for $W$ given the numerical value of $C$, or with infinie series which is not simple, or analytically on implicit form, that is with the inverse function of $F(X)\equiv\frac{X}{\tan(X)}$ $$W=F^{-1}(C)=F^{-1}\left(\frac{y'_1+y'_0}{2(y_1-y_0)}\right)$$ $$w=2F^{-1}\left(\frac{y'_1+y'_0}{2(y_1-y_0)}\right)$$ Bringing back $w$ into Eqs. $(3)$ gives $b$. Then $c=(y_0-b)$ and $a=\frac{y'_0}{w}$

In ADDITION :

The equation $(4)$ has an infinity of solutions. So, the numerical computation requires to specify which root one is looking for. They are several numerical methods. Of example a very simple algorithm (below, with explanation) comes from pages 324-325 in "An Atlas of Functions", J.Spanier, K.B.Oldham, Edit.Springer-Verlag, 1987.

enter image description here