Ways to construct a spline curve connecting two points

What are the various ways to construct a smooth (or at least continuously differentiable) curve that passes through two arbitrary points, given the slope of the curve at the two points?

For the sake of simplicity, let's start with this scenario:

Find a function *f*(*x*) defined on the interval [0,*a*] that passes horizontally through the origin [*f*(0) = *f'*(0) = 0] and passes through point (*a*,*b*) with slope *m*. You may assume that:

*a* > 0*b* > 0*m* > (*a*/*b*) [and therefore *m* > 0]*f*(*x*) >= 0*f'*(*x*) >= 0

In other words, you're looking for a spline curve that tangentially intersects the lines "*y*=0" and "*y*=*mx*+(*b*–*ma*)" at (0,0) and (*a*,*b*), respectively. (Note that the *x*-intercept of the latter line is at *x*>0.)

I've been trying to come up with solutions based on functions that satisfy *f*(0)=*f'*(0)=0 and which curve upward as *x* increases, scaled to fit into the box defined by (0,0) and (*a*,*b*) with the proper slope at (*a*,*b*), but I'm having trouble.

One thing I tried was scaling an arc of a circle. But I soon realized that there is only one possible circle whose center lies on the *y* axis and which passes through both (0,0) and (*a*,*b*), meaning an arbitrary slope value at (*a*,*b*) cannot be accommodated. (However, if the circle center is allowed to be to the right of the *y* axis, in some cases a circle arc could be found that tangentially intersects the *x* axis at *x*>0, with the function defined as *y*=0 between there and the origin.)

Next I tried a parabolic (2nd-order polynomial) function. But I couldn't figure out how to scale it in such a way that an arbitrary slope at (*a*,*b*) was possible.

A hyperbolic function might be workable, but I haven't tried it.

The trig-derived function *y=tan*^{2}x seems promising, but again, I couldn't figure out the scaling.

I know a Bézier curve could be used, but I'm looking for a solution that can be expressed as a non-parametric equation.

I think a power function based around some version of *y=x*^{c} — with *c* properly calculated from *a*, *b*, and *m* — could also be a solution.

Perhaps even an exponential function based around *y=e*^{x} could be made to work.

What suggestions do you have? Please explain your solutions!

Thanks,

~ Justin

1 Attachment(s)

Re: Ways to construct a spline curve connecting two points

Hi,

The easiest spline through your two given points (0,0) and (a,b) with required tangents is a cubic polynomial. See the attachment:

Attachment 28929

Re: Ways to construct a spline curve connecting two points

I've been playing around with exponential functions, and came up with a form that satisfies :

When , this function evaluates to . The function can be scaled to intersect (1,1) by dividing it by this figure.

A family of related functions that all satisfy and that all intersect (1,1) can be defined as follows:

What I found is that this family of functions has some interesting properties. As *k* approaches positive infinity, the plot hugs the *x* axis, then shoots straight up at *x*=1, much like *x*^{k} would. Where *k*=0, the function is undefined, but the limit as *k* approaches zero from either side is simply *y*=*x*^{2}. And the limit as *k* approaches negative infinity appears to be *y*=*x*.

What I'm thinking is that this family of functions that intersect (1,1) could simply be scaled to intersect (*a*,*b*) instead, with the value of *k* selected so that .

First, the scaling. We can "stretch" the function which intersects (1,1) to intersect (*a*,*b*) instead by making it .

We're almost there! Now we just have to figure out the correct value of *k* so that . Because of the way we scaled to obtain , by reversing the scaling we should be able to determine that .

Unfortunately, that's where I'm stuck, as I don't know how to differentiate . If I did, I could substitute and solve for *k* in terms of *m*, *a*, and *b*. Any help?

~ Justin

Re: Ways to construct a spline curve connecting two points

**johng**: Thanks for responding. I followed your solution as far as...

...but I'm not seeing how you get from there to:

Can you please clarify?

Thanks,

~ Justin

1 Attachment(s)

Re: Ways to construct a spline curve connecting two points

Hi,

I hope the attachment clarifies things:

Attachment 28931

Re: Ways to construct a spline curve connecting two points

Well done, __johng__! I had forgotten all about Cramer's Rule, and I missed the multiplication-then-subtraction approach you demonstrated. Thanks!

Can a general solution also be found using only a second-order polynomial?

Re: Ways to construct a spline curve connecting two points

Quote:

Originally Posted by

**jdmc** Unfortunately, that's where I'm stuck, as I don't know how to differentiate

Let ^{
img.top {vertical-align:15%;}
} and ^{
img.top {vertical-align:15%;}
} . Then .

Differentiating with respect to *x* yields: ^{
img.top {vertical-align:15%;}
} and ^{
img.top {vertical-align:15%;}
} .

Now, the Quotient Rule tells us that

Therefore

so

Remember that, as explained above,

Therefore

Unfortunately, I'm having trouble isolating on only one side of this equation. Help?

Re: Ways to construct a spline curve connecting two points

Can anyone help solve the last equation above for *k* ?