Curve fitting

Given a sine curve with phase phi (red curve). Between A and B the curve has been cut open. A is fixed at (0,0) and B can be adjusted with slider w. Try to find a cubic curve (green curve) that nicely fits in between the open ends of the sine curve. Use the sliders for a,b,c and d to adjust the coefficients. After trial and error, one can calculate the required coefficients (at boundaries continuity and equality first derivarives).