cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

what cspline() returns and how interp() works? 2 dimensions Mxy and Mz

LertPianapitham
5-Regular Member

what cspline() returns and how interp() works? 2 dimensions Mxy and Mz

Initially posted in this topic

 

Hi all,

i can understand this for single dimension vx and vy, but what about 2 dimensions Mxy and Mz? Could anyone explain what cspline() returns and how interp() works? Thx in advance!

Lert

Note: i use mathcad 15.

10 REPLIES 10

Hi,

Here is the Mathcad 15 Quicksheet for cspline(). It illustrates a 2D cubic spline.

Have added a 1D cubic spline example on Right Hand Side.

 

Cubic spline interpolation passes a curve through a set of points in such away that the first and second derivatives of the curve are continuous across each point. This curve is assembled by taking three adjacent points and constructing a cubic polynomial  passing through those points. These cubic polynomials are then strung together to form the completed curve.

 

Interp() uses the cubic polynomial curve coefficient values returned by cspline() to interpolate the cubic polynomial equations between points defining the cspline.

 

 Cheers

Terry

Thanks @terryhendicott , but i would like to know, how could i get the polynomial equation(s) as shown in the original post. Could you pls. explain this for bi-cubic spline as well?

Your question obviously stems from an older thread and was turned into a new thread by a moderator. Unfortunately the links he inserted refer to this thread and  not to the older one.

I already notified the mods and asked them to fix this. But maybe in the meantime you can provide the link to the older thread you are referring to when you write "as shown in the original post".

LertPianapitham
5-Regular Member
(To:Werner_E)

Oh, i didnt notice that. Thanks! Pls. find the original post there: https://community.ptc.com/t5/Mathcad/cspline/m-p/541847#M179328

To use the functions you do not need a detailed explanation of what is going on internal to the function.

first get a vector of cubic polynomial coefficients using cspline() using two vectors being the passing points x and y.

(In the case of bspline() the two vectors are the knots)

Use this vector of cubic polynomial coefficients, the two vectors being the passing points x and y, and the point of interest in the interp() function.

 

https://community.ptc.com/t5/Mathcad/cspline/m-p/541847#M179328

Shows how to get the coefficients?

 

Try this for full explanation of creating spline coefficients.

A cubic spline solution where you specify the starting and ending slope plus the points enclosed.  This will only confuse you.  But it shows how the coefficients are calculated.

 

Calculate the equations within a cubic spline for the coaster of n points with known x,y values.

Result is vector of Coefficients A, B, C, D for each segment with equation of

y(x) = A.x3 + B.x2 + C.x + D

d.y(x)/dx = 3.A.x2 + 2.B.x + C

d2.y(x)/dx2 = 6.A.x + 2.B

dy/dx and d2y/dx2 continuous at each internal point,

dy/dx specified at each end point.

# segments is s=n-1

4.s unknowns are coefficients A,B,C,D for each of these segments

2.s equations for y(x) at end of each segment

2 equations for dy/dx at ends

s-1 equations for dy/dx across internal points

s-1 equations for d2y/d2x across internal points

 

Using these equations a large matrix A and right hand side vector b is formed.

Solve the equations for the coefficients.

 

Interpolation is just using the correct coefficient A,B,C,D along the spline.

 

Capture.JPG

 

Cheers

Terry

 

Hi @terryhendicott 

sorry for late reply. i already understand, how cubic spline works (as shown in that old post). Now i want to understand the bi-cubic spline that applied by using Mxy - Mz instead of vx - vy. Do you know, how does it work? i would like to apply equation(s) in another function. Thx!

 

regards,

Lert

Hi Lert,

Enclosed is a file that shows 2D cspline interpolation of a surface Mz at point x_pt, y_pt

Below this is shown a sequence of 1D cspline interpolations vertical for each column of Mz at x_pt this produces the values for a cspline across the columns of Mz.

Interpolation across this new horizontal 1D cspline at point y_pt returns the same as the 2D interpolation.

 

Cheers

Terry

Hi @terryhendicott 

if i understand this correctly, there is multiple splines in x direction using 2nd derivative table created by cspline-function with Mxy - Mz (actually the 2nd variable of Mxy could be anything with the same dimension as cols(Mz)). Then we could use the results of these splines to create another spline in y direction. Does Mathcad also work like this?

 

Thx!

Lert

Hi,

I believe it does.

Cheers

Terry

See Please

Study 14. Interpolation, extrapolation and fitting Or Lies, damned lies and statistics

here 2⁵ Problems for STEM Education - 1st Edition - Valery Ochkov - Routl (routledge.com)

and

the chapter  15. Hydropower Thoughts and Calculations when Looking at a Banknote or Spline Interpolation

here STEM Problems with Mathcad and Python - 1st Edition - Valery Ochkov - (routledge.com)

Top Tags