NADCON5-ng  0.0.2
NADCON5 Next Generation Documentation
qterp.f
Go to the documentation of this file.
1 c> \ingroup core
2 c> \if MANPAGE
3 c> \page qterp
4 c> \endif
5 c>
6 c> This function fits a quadratic function through 3 points
7 c>
8 c> This function fits a parabola (quadratic) function through
9 c> three *equally* spaced points along the x-axis
10 c> at indices 0, 1, and 2. The spacing along the
11 c> x-axis is "dx"
12 c>
13 c> Thus:
14 c>
15 c> \f{eqnarray*}{
16 c> f0 = f_0 &= y(x_0) \\
17 c> f1 = f_1 &= y(x_1) \\
18 c> f2 = f_2 &= y(x_2)
19 c> \f}
20 c>
21 c> Where:
22 c>
23 c> \f{eqnarray*}{
24 c> x_1 &= x_0 + dx \\
25 c> x_2 &= x_1 + dx \\
26 c> x_3 &= x_2 + dx
27 c> \f}
28 c>
29 c> The input value is some value of "x" that falls
30 c> between 0 and 2. The output value (qterp) is
31 c> the quadratic function at x.
32 c>
33 c>
34 c> \param[in] x Compute Interpolation at this positon, a value between 0 and 3
35 c> it is scaled relative to `x_0` `x_2` and `dx`. For example,
36 c> the value of 1.5 is `x_0 + 1.5*dx` which falls between `x1` and `x2`
37 c> \param[in] f0 `y` value at `x_0`
38 c> \param[in] f1 `y` value at `x_1 = x_0 + dx`
39 c> \param[in] f2 `y` value at `x_2 = x_0 + dx`
40 c> \return `real` quadratically interpolated value of `f(x*)` where `x* = x_0 + x*dxx`
41 c>
42 c> This function uses Newton-Gregory forward polynomial
43 c>
44 c> \f{eqnarray*}{
45 c> \nabla f_0 &=& f_1 -f_0 \\
46 c> \nabla f_1 &=& f_2 -f_1 \\
47 c> \nabla^2 f_0 &=& \nabla f_1 - \nabla f_0 \\
48 c> qterp(x, f_0, f_1, f_2) &=& f_0 + x \nabla f_0 + 0.5 x \left( x-1.0 \right) \nabla^2 f_0
49 c> \f}
50  real function qterp(x,f0,f1,f2)
51 
52 c - x = real*4
53 c - f0,f1,f2 = real*4
54 
55 c - This function fits a parabola (quadratic) through
56 c - three points, *equally* spaced along the x-axis
57 c - at indices 0, 1 and 2. The spacing along the
58 c - x-axis is "dx"
59 c - Thus:
60 c -
61 c - f0 = y(x(0))
62 c - f1 = y(x(1))
63 c - f2 = y(x(2))
64 c - Where
65 c - x(1) = x(0) + dx
66 c - x(2) = x(1) + dx
67 
68 c - The input value is some value of "x" that falls
69 c - between 0 and 2. The output value (qterp2) is
70 c - the parabolic function at x.
71 c -
72 c - This function uses Newton-Gregory forward polynomial
73 
74  df0 =f1 -f0
75  df1 =f2 -f1
76  d2f0=df1-df0
77 
78  qterp=f0 + x*df0 + 0.5*x*(x-1.0)*d2f0
79 
80  return
81  end
real function qterp(x, f0, f1, f2)
This function fits a quadratic function through 3 points.
Definition: qterp.f:51