Piecewise Function Smooth Join Calculator

Enter the points and slopes of two outside lines. Construct a smooth cubic transition, compare its value and slope profiles with a straight join, and inspect exact limits and coefficients.

Piecewise interpolation

Build a smooth join between two lines

Endpoint values and slopes

Enter where each outside line meets the join. Slopes use y units per x unit.

Left line
Right line

The smooth join stays in the endpoint band without reversing.

Transition checks

Smooth join direction
Increasing
Smooth join range
Stays within endpoint values
Smooth slope range
0 to 25/9
Straight join slope
2

Straight slope minus outside slope at the left and right joins2 / 1

Inspect the transition

50% across the join

Compare the smooth and straight joins
Value profile of the two joinsThe smooth join stays in the endpoint band without reversing. The probe is 50 percent across the join.Left joinRight join
Smooth join Straight join Outside lines ProbeEndpoint value band
Probe x
2
Smooth value
11/2
Smooth slope
11/4
Straight value
6

Export the join audit

View exact coefficients and slope limits
t³ coefficient
-12
t² coefficient
20
t coefficient
0
Constant
2
Minimum slope
0
x = 0
Maximum slope
25/9
x = 20/9

t = (x − left x) / join width

View CSV text

How to use this calculator

  1. Enter x, value, and slope where the left and right lines meet the transition.
  2. Check whether the cubic moves in one direction and stays within the endpoint values.
  3. Switch between the value and slope plots. Move the probe to read the exact value and slope at that position.
  4. Open the coefficient and slope ledger or download the complete CSV.

The Formula

The mathematical logic powering this calculation is:

Let the given endpoint positions be x₀ < x₁ with values y₀ and y₁ and slopes m₀ and m₁. Write h = x₁ − x₀, t = (x − x₀)/h, and Δ = y₁ − y₀. A cubic Hermite join is p(t) = at³ + bt² + ct + y₀, where a = h(m₀ + m₁) − 2Δ, b = 3Δ − h(2m₀ + m₁), and c = hm₀. This gives the endpoint values and matches derivatives with respect to x. Outside the join, continue the line from each endpoint using its supplied slope.

The straight join is y₀ + Δt and has slope Δ/h. At each endpoint, compare that slope with the given outside slope. The cubic’s slope is (3at² + 2bt + c)/h. A quadratic’s minimum and maximum occur at its endpoints or at an interior vertex. If the exact slope takes both positive and negative values, the cubic changes direction on the join interval. An isolated zero slope is allowed on a monotone join.

To test the endpoint value band, factor p(t) − y₀ as t(at² + bt + c) and y₁ − p(t) as (1 − t)(at² + (a + b)t + Δ). Both outside factors are positive for 0 < t < 1. Check the signs of the quadratics at their endpoints and interior vertices, using the order of y₀ and y₁. This distinguishes a curve that reverses but stays inside the band from one that exceeds an endpoint value. A curve can touch the boundary and still stay within the band.

Enter decimals from −1,000,000 through 1,000,000 with up to six fractional places. Coefficients, slope limits and all classification tests use exact fractions. The chart uses drawing coordinates derived from the same curves. The cubic matches values and first derivatives at the joins. Curvature can change across either boundary.

Worked Example

If you input:

  • Left x, value, slope: 0, 2, 0
  • Right x, value, slope: 4, 10, 1

Result:

The join is p(t) = −12t³ + 20t² + 2, with t = x/4. It increases and stays between 2 and 10. At x = 2 its value is 11/2 and its slope is 11/4. The straight segment has slope 2.

Frequently Asked Questions

Why can a smooth transition overshoot?

Matching both endpoint tangents can send the cubic in different directions across the interval. The size and sign of each slope, relative to the slope of the straight join, affect the curve.

Can the curve reverse direction without overshooting?

Yes. The curve can rise, fall, and rise again while staying inside the value band defined by its two endpoints.

What does matching the slopes make continuous?

Both the value and first derivative agree with the outside lines at each join. This is C¹ continuity. Matching curvature would impose a second-derivative condition.

Can the join end at the same height it starts?

Yes. With equal values the endpoint band has zero thickness. Any nonconstant join leaves that band. Both slopes must be zero to keep the entire join constant.

Similar Calculators