Back to section

NavArch Handbook

Chapter 1 / Section 1.6

Interpolation and curve fitting of tabulated data

Linear interpolation

Between two tabulated points (x0,y0)(x_0, y_0)(x0​,y0​), (x1,y1)(x_1, y_1)(x1​,y1​):

y=y0+(x−x0) y1−y0x1−x0y = y_0 + (x - x_0)\,\frac{y_1 - y_0}{x_1 - x_0}y=y0​+(x−x0​)x1​−x0​y1​−y0​​

Adequate for hydrostatic tables at 0.1 m draught steps, KN tables at 10° steps within the linear range, and material property tables. Error is proportional to the second derivative of the underlying curve times the square of the interval.

Quadratic (Lagrange) interpolation

Through three points (x0,y0),(x1,y1),(x2,y2)(x_0,y_0), (x_1,y_1), (x_2,y_2)(x0​,y0​),(x1​,y1​),(x2​,y2​):

y(x)=∑i=02yi∏j≠ix−xjxi−xjy(x) = \sum_{i=0}^{2} y_i \prod_{j \ne i} \frac{x - x_j}{x_i - x_j}y(x)=i=0∑2​yi​j=i∏​xi​−xj​x−xj​​

Use for curved tables (KM vs draught near its minimum, GZ near its maximum, MCT1cmMCT1cmMCT1cm) and for locating the maximum of a tabulated curve: the vertex of the parabola through three equally spaced points y−1,y0,y+1y_{-1}, y_0, y_{+1}y−1​,y0​,y+1​ (spacing hhh) lies at

xmax⁡=x0+h2 y−1−y+1y−1−2y0+y+1,ymax⁡=y0−(y+1−y−1)28 (y−1−2y0+y+1)x_{\max} = x_0 + \frac{h}{2}\,\frac{y_{-1} - y_{+1}}{y_{-1} - 2y_0 + y_{+1}}, \qquad y_{\max} = y_0 - \frac{(y_{+1} - y_{-1})^2}{8\,(y_{-1} - 2y_0 + y_{+1})}xmax​=x0​+2h​y−1​−2y0​+y+1​y−1​−y+1​​,ymax​=y0​−8(y−1​−2y0​+y+1​)(y+1​−y−1​)2​

This is how the angle of maximum GZ is found from 10° ordinates (Tools page, IS Code check).

Cubic splines

Piecewise cubics with continuous first and second derivatives through all points; the standard method in hydrostatics software for curves of KN, areas and Bonjean curves. Do not hand-compute; be aware that splines can oscillate near sharp changes (deck-edge immersion, knuckles) — check against the tabulated values.

Extrapolation

Never extrapolate hydrostatic or KN tables beyond the tabulated range; the hull form changes (deck immersion, bilge emergence) make the curves non-polynomial.

Least-squares straight line (regression)

For nnn points (xi,yi)(x_i, y_i)(xi​,yi​):

b=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2,a=yˉ−b xˉb = \frac{\sum (x_i - \bar x)(y_i - \bar y)}{\sum (x_i - \bar x)^2}, \qquad a = \bar y - b\,\bar xb=∑(xi​−xˉ)2∑(xi​−xˉ)(yi​−yˉ​)​,a=yˉ​−bxˉ

Through the origin (physically required, e.g. inclining moment vs tan⁡φ\tan\varphitanφ): b=∑xiyi/∑xi2b = \sum x_i y_i / \sum x_i^2b=∑xi​yi​/∑xi2​. Goodness of fit: R2R^2R2 (Section 1.8). Plot the residuals; a systematic pattern means the model (straight line) is wrong, not the data.

Polynomial and power-law fits

Resistance and power data are often fitted as P=a VbP = a\,V^bP=aVb (straight line in log–log); hydrostatic coefficients are sometimes given as polynomials in draught. Fit the lowest degree that follows the physics; a 5th-degree polynomial through 7 points reproduces the noise, not the curve.

Interpolation in two variables (bilinear)

KN tables are two-dimensional (displacement × heel angle): interpolate linearly in displacement at each tabulated angle first, then in angle if needed.

Formulas

01Linear interpolation
y=y0+(x−x0) y1−y0x1−x0y = y_0 + (x - x_0)\,\frac{y_1 - y_0}{x_1 - x_0}y=y0​+(x−x0​)x1​−x0​y1​−y0​​
SymbolDescriptionUnit
x0,x1x_0, x_1x0​,x1​Tabulated arguments bracketing xas given
y0,y1y_0, y_1y0​,y1​Tabulated valuesas given

Result unit as given

02Lagrange quadratic interpolation
y(x)=y0(x−x1)(x−x2)(x0−x1)(x0−x2)+y1(x−x0)(x−x2)(x1−x0)(x1−x2)+y2(x−x0)(x−x1)(x2−x0)(x2−x1)y(x) = y_0\frac{(x-x_1)(x-x_2)}{(x_0-x_1)(x_0-x_2)} + y_1\frac{(x-x_0)(x-x_2)}{(x_1-x_0)(x_1-x_2)} + y_2\frac{(x-x_0)(x-x_1)}{(x_2-x_0)(x_2-x_1)}y(x)=y0​(x0​−x1​)(x0​−x2​)(x−x1​)(x−x2​)​+y1​(x1​−x0​)(x1​−x2​)(x−x0​)(x−x2​)​+y2​(x2​−x0​)(x2​−x1​)(x−x0​)(x−x1​)​

Result unit as given

03Maximum of a parabola through three equally spaced points
xmax⁡=x0+h2 y−1−y+1y−1−2y0+y+1,ymax⁡=y0−(y+1−y−1)28 (y−1−2y0+y+1)x_{\max} = x_0 + \frac{h}{2}\,\frac{y_{-1} - y_{+1}}{y_{-1} - 2y_0 + y_{+1}}, \qquad y_{\max} = y_0 - \frac{(y_{+1} - y_{-1})^2}{8\,(y_{-1} - 2y_0 + y_{+1})}xmax​=x0​+2h​y−1​−2y0​+y+1​y−1​−y+1​​,ymax​=y0​−8(y−1​−2y0​+y+1​)(y+1​−y−1​)2​
SymbolDescriptionUnit
y−1,y0,y+1y_{-1}, y_0, y_{+1}y−1​,y0​,y+1​Three consecutive ordinates with y_0 the largest tabulatedas given
hhhSpacing of the argumentsas given

Result unit as given

Used to find the angle of maximum GZ from 10° ordinates.

04Least-squares straight line
b=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2,a=yˉ−b xˉb = \frac{\sum (x_i - \bar x)(y_i - \bar y)}{\sum (x_i - \bar x)^2}, \qquad a = \bar y - b\,\bar xb=∑(xi​−xˉ)2∑(xi​−xˉ)(yi​−yˉ​)​,a=yˉ​−bxˉ
SymbolDescriptionUnit
bbbSlope(unit y)/(unit x)
aaaInterceptunit y

Result unit -

05Least-squares line through the origin
b=∑xi yi∑xi2b = \frac{\sum x_i\,y_i}{\sum x_i^2}b=∑xi2​∑xi​yi​​

Result unit -

Use when the physics requires y = 0 at x = 0 (inclining test: moment vs tan φ).

06Power-law fit by log–log regression
y=a xb  ⇔  log⁡y=log⁡a+blog⁡xy = a\,x^b \;\Leftrightarrow\; \log y = \log a + b\log xy=axb⇔logy=loga+blogx

Result unit -

Examples

#01

Interpolating KM from the hydrostatic table

Worked example

Problem

The example vessel's hydrostatic table (Section 4.8) gives KMTKM_TKMT​ = 6.21 m at T = 4.50 m, 6.08 m at 5.00 m and 5.92 m at 6.00 m. Estimate KMTKM_TKMT​ at T = 5.50 m by (a) linear interpolation between 5.00 and 6.00 m and (b) quadratic interpolation through the three points, and compare with the tabulated 5.98 m.

Solution

(a) Linear: KM=6.08+(5.50−5.00) 5.92−6.086.00−5.00=6.08−0.08=6.00KM = 6.08 + (5.50 - 5.00)\,\dfrac{5.92 - 6.08}{6.00 - 5.00} = 6.08 - 0.08 = 6.00KM=6.08+(5.50−5.00)6.00−5.005.92−6.08​=6.08−0.08=6.00 m.

(b) Lagrange with x0=4.5x_0 = 4.5x0​=4.5, x1=5.0x_1 = 5.0x1​=5.0, x2=6.0x_2 = 6.0x2​=6.0, x=5.5x = 5.5x=5.5:

L0=(5.5−5.0)(5.5−6.0)(4.5−5.0)(4.5−6.0)=−0.250.75=−0.3333L_0 = \dfrac{(5.5-5.0)(5.5-6.0)}{(4.5-5.0)(4.5-6.0)} = \dfrac{-0.25}{0.75} = -0.3333L0​=(4.5−5.0)(4.5−6.0)(5.5−5.0)(5.5−6.0)​=0.75−0.25​=−0.3333; L1=(5.5−4.5)(5.5−6.0)(5.0−4.5)(5.0−6.0)=−0.5−0.5=1.000L_1 = \dfrac{(5.5-4.5)(5.5-6.0)}{(5.0-4.5)(5.0-6.0)} = \dfrac{-0.5}{-0.5} = 1.000L1​=(5.0−4.5)(5.0−6.0)(5.5−4.5)(5.5−6.0)​=−0.5−0.5​=1.000; L2=(5.5−4.5)(5.5−5.0)(6.0−4.5)(6.0−5.0)=0.51.5=0.3333L_2 = \dfrac{(5.5-4.5)(5.5-5.0)}{(6.0-4.5)(6.0-5.0)} = \dfrac{0.5}{1.5} = 0.3333L2​=(6.0−4.5)(6.0−5.0)(5.5−4.5)(5.5−5.0)​=1.50.5​=0.3333.

KM=−0.3333×6.21+1.000×6.08+0.3333×5.92=−2.070+6.080+1.973=5.983KM = -0.3333 \times 6.21 + 1.000 \times 6.08 + 0.3333 \times 5.92 = -2.070 + 6.080 + 1.973 = 5.983KM=−0.3333×6.21+1.000×6.08+0.3333×5.92=−2.070+6.080+1.973=5.983 m.

The quadratic value (5.98 m) matches the table; the linear value is 2 cm high because KM is concave upward near its minimum. A 2 cm error in KM is a 2 cm error in GM — significant when GM is 0.70 m.

#02

Angle of maximum GZ from 10° ordinates

Worked example

Problem

GZ values (Example 5.4): 0.485 m at 30°, 0.536 m at 40°, 0.446 m at 50°. Find the angle and value of maximum GZ.

Solution

y−1=0.485y_{-1} = 0.485y−1​=0.485, y0=0.536y_0 = 0.536y0​=0.536, y+1=0.446y_{+1} = 0.446y+1​=0.446, h=10°h = 10°h=10°.

φmax⁡=40+102 0.485−0.4460.485−2×0.536+0.446=40+5×0.039−0.141=40−1.38=38.6°\varphi_{\max} = 40 + \frac{10}{2}\,\frac{0.485 - 0.446}{0.485 - 2 \times 0.536 + 0.446} = 40 + 5 \times \frac{0.039}{-0.141} = 40 - 1.38 = 38.6°φmax​=40+210​0.485−2×0.536+0.4460.485−0.446​=40+5×−0.1410.039​=40−1.38=38.6° GZmax⁡=0.536−(0.446−0.485)28×(−0.141)=0.536+0.00135=0.537 mGZ_{\max} = 0.536 - \frac{(0.446 - 0.485)^2}{8 \times (-0.141)} = 0.536 + 0.00135 = 0.537\ \text{m}GZmax​=0.536−8×(−0.141)(0.446−0.485)2​=0.536+0.00135=0.537 m

These are the values the Tools page reports (38.6°, 0.537 m). The criterion φmax⁡≥25°\varphi_{\max} \ge 25°φmax​≥25° is satisfied.

References

Press, Teukolsky, Vetterling & Flannery, Numerical Recipes, 3rd ed. (2007)Clause Ch. 3 (Interpolation and extrapolation), Ch. 15 (Modeling of data — least squares)Textbook
Rawson & Tupper, Basic Ship Theory, 5th ed. (2001)Clause Vol. 1, Ch. 2 (Interpolation of ship curves; drawing of curves through spots)Textbook
NavArch Handbook · Chapter 1 · printed on —