As a combination of the different suggestions, you could also use a simple interpolate() - interpolate() to calculate the difference and then use the lambda setting of the smoother plot to tune the granularity of the curve.
Open( "$DOWNLOADS/ab.jmp" );
New Column( "diff",
Formula(
rowsA = As Constant( Current Data Table() << get rows where( :Source Table == "a" ) );
rowsB = As Constant( Current Data Table() << get rows where( :Source Table == "b" ) );
xA = As Constant( :time[rowsA] );
xB = As Constant( :time[rowsB] );
posA = As Constant( :position[rowsA] );
posB = As Constant( :position[rowsB] );
If( Min( xA ) <= :time <= Max( xA ) & Min( xB ) <= :time <= Max( xB ),
Interpolate( :time, xA, posA ) - Interpolate( :time, xB, posB ),
.
);
)
);
Graph Builder(
Variables( X( :time ), Y( :diff ), Y( :position ), Overlay( :Source Table ) ),
Elements( Position( 1, 1 ), Points( X, Y, Overlay( 0 ), Legend( 1 ) ), Smoother( X, Y, Overlay( 0 ), Lambda( 0.02 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y ), Smoother( X, Y ) )
);