Curve fitting with linear combination of nonlinear functions.
The following data is obtained from wind-tunnel tests, for the variation of the ratio of the tangential velocity of a vortex to the free stream flow velocity y=V_{\theta} / V_{\infty} versus the ratio of the distance from the vortex core to the chord of an aircraft wing, x=R / C :
\begin{array}{llllllllllll}x & 0.6 & 0.8 & 0.85 & 0.95 & 1.0 & 1.1 & 1.2 & 1.3 & 1.45 & 1.6 & 1.8 \\ y & 0.08 & 0.06 & 0.07 & 0.07 & 0.07 & 0.06 & 0.06 & 0.06 & 0.05 & 0.05 & 0.04\end{array}Theory predicts that the relationship between x and y should be of the form y=\frac{A}{x}+\frac{B e^{-2 x^{2}}}{x}. Find the values of A and B using the least-squares method to fit the above data.
In the notation of Eq. (6.91)
F(x)=C_1 f_1(x)+C_2 f_2(x)+C_3 f_3(x)+\ldots+C_m f_m(x)=\sum\limits_{j=1}^m C_j f_j\left(x_i\right) (6.91)
the approximating function is F(x)=C_{1} f_{1}(x)+C_{2} f_{2}(x) with F(x)=y, C_{1}=A, C_{2}=B, f_{1}(x)=\frac{1}{x}, and f_{2}(x)=\frac{e^{-2 x^{2}}}{x}. The equation has two terms, which means that m=2, and since there are 11 data points, n=11. Substituting this information in Eq. (6.97)
\sum\limits_{i=1}^n \sum\limits_{j=1}^m C_j f_j\left(x_i\right) f_k\left(x_i\right)=\sum\limits_{i=1}^n y_i f_k\left(x_i\right) \text { for } k=1,2, \ldots, m (6.97)
gives the following system of two linear equations for A and B.
\begin{gathered} \sum\limits_{i=1}^{11} A \frac{1}{x_{i}} \frac{1}{x_{i}}+\sum\limits_{i=1}^{11} B \frac{e^{-2 x_{i}^{2}}}{x_{i}} \frac{1}{x_{i}}=\sum\limits_{i=1}^{11} y_{i} \frac{1}{x_{i}} \quad \text { for } k=1 \\ \sum\limits_{i=1}^{11} A \frac{1}{x_{i}} \frac{e^{-2 x_{i}^{2}}}{x_{i}}+\sum\limits_{i=1}^{11} B \frac{e^{-2 x_{i}^{2}}}{x_{i}} \frac{e^{-2 x_{i}^{2}}}{x_{i}}=\sum\limits_{i=1}^{11} y_{i} \frac{e^{-2 x_{i}^{2}}}{x_{i}} \text { for } k=2 \end{gathered}
These two equations can be rewritten as:
\begin{aligned} A \sum\limits_{i=1}^{11} \frac{1}{x_{i}^{2}}+B \sum\limits_{i=1}^{11} \frac{e^{-2 x_{i}^{2}}}{x_{i}^{2}} & =\sum\limits_{i=1}^{11} y_{i} \frac{1}{x_{i}} \\ A \sum\limits_{i=1}^{11} \frac{e^{-2 x_{i}^{2}}}{x_{i}^{2}}+B \sum\limits_{i=1}^{11} \frac{e^{-4 x_{i}^{2}}}{x_{i}^{2}} & =\sum\limits_{i=1}^{11} y_{i} \frac{e^{-2 x_{i}^{2}}}{x_{i}} \end{aligned}
The system can be written in a matrix form:
\left[\begin{array}{cc} \sum\limits_{i=1}^{11} \frac{1}{x_{i}^{2}} & \sum\limits_{i=1}^{11} \frac{e^{-2 x_{i}^{2}}}{x_{i}^{2}} \\ \sum\limits_{i=1}^{11} \frac{e^{-2 x_{i}^{2}}}{x_{i}^{2}}& \sum\limits_{i=1}^{11} \frac{e^{-4 x_{i}^{2}}}{x_{i}^{2}} \end{array}\right]\left[\begin{array}{l} A \\ B \end{array}\right]=\left[\begin{array}{c} \sum\limits_{i=1}^{11} y_{i} \frac{1}{x_{i}} \\ \sum\limits_{i=1}^{11} y_{i} \frac{e^{-2 x_{i}^{2}}}{x_{i}} \end{array}\right]
The system is solved by using MATLAB. The following MATLAB program in a script file solves the system and then makes a plot of the data points and the curve-fitted function.
x = [0.6 0.8 0.85 0.95 1.0 1.1 1.2 1.3 1.45 1.6 1.8];
y = [0.08 0.06 0.07 0.07 0.07 0.06 0.06 0.06 0.05 0.05 0.04];
a ( 1 , 1) = sum ( 1. Ix . "^2) ;
a(l,2) = sum(exp(-2*x."^2) ./x."^2);
a(2,1) = a(1,2);
a(2,2) = sum(exp(-4*x."^2) ./x."^2);
b(1,1) = sum(y./x);
b(2,1) = sum((y.*exp(-2*x."^2)) ./x);
AB= a\b
xfit = 0.6:0.02:1.8;
yfit = AB(l) ./xfit + AB(2)*exp(-2*xfit.^2) ./xfit;
plot(x,y,'o' ,xfit,yfit)
When the program is executed, the solution for the coefficients is displayed in the Command Window (the two elements of the vector A B ), and a plot with the data points and the curve-fitted function is created.
Command Window:
AB =
0.0743
-0.0597
The coefficient A.
The coefficient B.