Download ppt - Computational Physics

Transcript
Page 1: Computational Physics

Prof. Muhammad Saeed

( Interpolation and Curve Fitting )

Page 2: Computational Physics

2M.Sc. Physics

1.1.InterpoInterpolationlationa) Newton-Gregory Forward

Formula

Evenly Spaced Data

Page 3: Computational Physics

M.Sc. Physics 3

a) Lagrange Polynomials (Cubic)

Unevenly Spaced Data

b)Divided Difference

Page 4: Computational Physics

M.Sc. Physics 4

c) Cubic Spline

For condition 1 (Natural Spline):

2(h0+h1) h1 0 0 0 0   S1   f[x1,x2] - f[x0,x1]

h1 2(h1+h2) h2 0 0 0   S2   f[x2,x3] - f[x1,x2]

0 h2 2(h2+h3) h3 0 0   S3   f[x3,x4] - f[x2,x3]

0 0 h3 2(h3+h4) h4 0   S4   = 6   f[x4,x5] - f[x3,x4]

0 0 0 .. .. ..   ….   ….

0 0 0 0   ….   …..

0 0 0 0 hn-2 2(hn-2+hn-1)   Sn-1   f[xn-1,xn] - f[xn-2,xn-1]

Page 5: Computational Physics

M.Sc. Physics 5

2.2.Curve Curve FittingFitting

Least-Squares Approximations

Functions to Fit1) y = mx+c2) Polynomial2) y = aebx

3) y = a log(x) + b4) y = axb

5)

6) y = ax2 +bx

baxy

1

y= a

Page 6: Computational Physics

M.Sc. Physics 6

N ∑x ∑x2 ∑x3 …. ∑xn   a0   ∑ Y

∑x ∑x2 ∑x3 ∑x4 …. ∑xn+1   a1   ∑xY

∑x2 ∑x3 ∑x4 ∑x5 ….. ∑xn+2   a2   ∑x2Y

… …. …. …. ….. …   a3   =    ….

…. … … … ….. …   ….   …

… … …. … ….. ….   ….   …

∑xn ∑xn+1 ∑xn+2 ∑xn+3 …. ∑x2n   an   ∑xnY

a) Polynomial Fit

The Best Fit is determined by the minimum value of

Page 7: Computational Physics

M.Sc. Physics 7

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15Weight 10.0 12.0 15.0 17.0 20.0 27.0 35.0 41.0 48.0 50.0 51.0 54.0 59.0 66.0 75.0

Height 0.75 0.86 0.95 1.08 1.12 1.26 1.35 1.51 1.55 1.60 1.63 1.67 1.71 1.78 1.85

Use W=aHb as mathematical model

Problem:Weight to Height Ratio of Human Beings

Page 8: Computational Physics

M.Sc. Physics 8

b) Line Regression

Page 9: Computational Physics

M.Sc. Physics 9

c) Polynomial Regression

‘m’ is the degree of polynomial

Page 10: Computational Physics

M.Sc. Physics 10


Recommended