Seamlessly connect a sine curve and a parabola

$\begingroup$

I want to seamlessly connect an unknown parabola to a known sine wave. The equations are:

s(x) = a sin(bx + c)
p(x) = Ax^2 + Bx + C

I want to draw p(x) from 0 to Z and s(x) from Z to Y.

a, b, c, Z and Y are know and I want to calculate A, B and C such as s(Z) = p(Z), s'(Z) = p'(Z) and p(x) is centered on x = 0.


Somebody on StackOverflow suggested

A = ab cos(c) / (2Z)
B = 0
C = a sin(c) - A Z^2

by assuming that I wanted s(0) = p(Z) and s'(0) = p'(Z), but that didn't work for me. See the question linked above for additional information and some visualizations of the functions.


How should I calculate A, B and C?

$\endgroup$ 1

2 Answers

$\begingroup$

Note that the center of a parabola is at $x=-\frac{B}{2A}$, so $B=0$.

Now solve in Mathematica and plot the result:

s[x_] := a Sin[b x + c];
p[x_] := A x^2 + C;
rule = Solve[s[Z] == p[Z] && s'[Z] == p'[Z], {A, C}][[1]]
f[x_] := Piecewise[{{p[x] /. rule, x < Z}, {s[x], x >= Z}}];
Plot[f[x] /. {Z -> 0.8, a -> 1, b -> 15, c -> -3}, {x, 0, 2}]

producing the answer:

$$\left\{\left\{A\to \frac{a b \cos (b Z+c)}{2 Z},C\to \frac{1}{2} (2 a \sin (b Z+c)-a b Z \cos (b Z+c))\right\}\right\}$$

(you can reuse $A$ on the $C$ calculation by doing $C\to a \sin (b Z+c)-AZ^2$).

An example plot:

enter image description here

$\endgroup$ 7 $\begingroup$

I don't have time for a detailed response, but you need to write three equations. One will define the exact location at which these curves will link up. The other will make sure the derivatives are equal at this point. The third will ensure the second derivatives equal at this point. Then you should have a "seamless" transition between these two curves.

You have three unknowns, $A, B, ~$and$~C$. You have three equations for location, derivative, and second derivative. The system of equations should be solvable.

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like