# Fitting a sine wave between two lines

• Jan 28th 2013, 07:49 AM
charlieahill
Fitting a sine wave between two lines
I have a data set that appears to be made up of two linear regions, separated by what best looks like a sine wave.

http://charliehillgroup.com/Characte...n data set.bmp

I know the x and y co-ordinates of the two points at the end of each line segment, x1, x2, y1, y2, and the respective gradient of the lines, m1 and m2.

I believe I can parameterise a sine wave of the form "y = Asin(Bx+C)+D" so that it passes through the given points, with the same gradient, but can't work out how to solve for the parameters.

Does anybody have any ideas?
Thanks!
• Jan 28th 2013, 08:17 AM
JJacquelin
Re: Fitting a sine wave between two lines
Hi !
The shape of the curve looks like an hyperbola (non orthogonal).
I suggest to fit the curve (least squares fitting method, involving 5 parameters) to the general quadratic equation and then, compute the characteristic parameters of the hyperbola.
It might be much simpler if you already know the gradient of the asymtotes m1 and m2 . In this case, the equation of the hyperbola is :
(y-m1*x+C1)*(y-m2*x+C2)+C3=0
C1, C2 and C3 can be computed thanks to a linear regression involving 3 parameters (to be defined in relation with C1, C2, C3).
• Jan 29th 2013, 03:14 AM
charlieahill
Re: Fitting a sine wave between two lines
Hi,

This works, thanks for the reply!

If anyone has any ideas, I'd still be interested to know whether it's possible to fit a sine wave under these conditions as a matter of interest.
• Jan 29th 2013, 04:28 AM
JJacquelin
Re: Fitting a sine wave between two lines
Quote:

Originally Posted by charlieahill
If anyone has any ideas, I'd still be interested to know whether it's possible to fit a sine wave under these conditions as a matter of interest.

Fitting a sine function y = Asin(Bx+C)+D to experimental data is a difficult problem. Of course only the points on the area of the sine wave have to be considered and the other points excluded. Since they are 4 parameters A, B, C, D to be optimized, the number of experimental points must be large enough.
A method is discribed in the paper "Régressions et équations intégrales" : JJacquelin's Documents | Scribd
(in French. No translation available today) which includes a chapter "Régression sinusoidale" : theory and application pp.21-34 and usable equations pp.35-36