Mathcad - Curve Fitting Cubic Spline - ODTÜ Web Servisiusers.metu.edu.tr/ender/Mathcad - Curve...

3
Mathcad Tutorial on Curve Fitting - Cubic Spline N 20 Δx 0.15 i 0 N fx () sin 2.5 x ( ) 1.2 x vx i i Δx vy i f vx i 0 1 2 3 0 1 2 3 4 vy vx Cubic Spline Fit vs cspline vx vy ( ) g x () interp vs vx vy x ( ) vs pspline vx vy ( ) hx () interp vs vx vy x ( ) vs lspline vx vy ( ) jx () interp vs vx vy x ( ) 0 1 2 3 0 2 4 6 8 vy gx () hx () jx () vx x Middle East Technical University, METU, Ankara/TURKEY 1 Dr. Ender CİĞEROĞLU

Transcript of Mathcad - Curve Fitting Cubic Spline - ODTÜ Web Servisiusers.metu.edu.tr/ender/Mathcad - Curve...

Page 1: Mathcad - Curve Fitting Cubic Spline - ODTÜ Web Servisiusers.metu.edu.tr/ender/Mathcad - Curve Fitting_Cubic_Spline.pdf · Mathcad Tutorial on Curve Fitting - Cubic Spline Regression

Mathcad Tutorial on Curve Fitting - Cubic Spline

N 20 Δx 0.15i 0 N f x( ) sin 2.5 x( ) 1.2 x

vxi i Δx vyi f vxi

0 1 2 30

1

2

3

4

vy

vx

Cubic Spline Fit

vs cspline vx vy( ) g x( ) interp vs vx vy x( )

vs pspline vx vy( ) h x( ) interp vs vx vy x( )

vs lspline vx vy( ) j x( ) interp vs vx vy x( )

0 1 2 30

2

4

6

8

vy

g x( )

h x( )

j x( )

vx x

Middle East Technical University, METU, Ankara/TURKEY

1

Dr. Ender CİĞEROĞLU

Page 2: Mathcad - Curve Fitting Cubic Spline - ODTÜ Web Servisiusers.metu.edu.tr/ender/Mathcad - Curve Fitting_Cubic_Spline.pdf · Mathcad Tutorial on Curve Fitting - Cubic Spline Regression

Mathcad Tutorial on Curve Fitting - Cubic Spline

Regression Fit by Linear Combination of Functions

F x( )sin 2.5 x( )

x

V linfit vx vy F( ) V1

1.2

k x( ) V F x( )

0 1 2 30

1

2

3

4

5

vy

k x( )

vx x

F x( )sin 2.2 x( )

x

V linfit vx vy F( ) V0.934

1.306

l x( ) V F x( )

0 1 2 30

2

4

6

vy

k x( )

l x( )

vx x

Differentiation and Integration of Data Sets

After cubic spline fitting we have an analytical equation for the function in terms of3rd order polynomials, for which we can calculate the derivative or which we can

Middle East Technical University, METU, Ankara/TURKEY

2

Dr. Ender CİĞEROĞLU

Page 3: Mathcad - Curve Fitting Cubic Spline - ODTÜ Web Servisiusers.metu.edu.tr/ender/Mathcad - Curve Fitting_Cubic_Spline.pdf · Mathcad Tutorial on Curve Fitting - Cubic Spline Regression

Mathcad Tutorial on Curve Fitting - Cubic Spline

p yintegrate.

0 1 2 32

0

2

4

Exact DerivativeDerivative from Spline Fit

xf x( )

d

d

xg x( )

d

d

x

0

π

2

xf x( )

d 2.1632833726 Numerical Integration of Exact Function

0

π

2

xg x( )

d 2.1632800248 Numerical Integration of Spline Fitted Function

Middle East Technical University, METU, Ankara/TURKEY

3

Dr. Ender CİĞEROĞLU