The problem: approximate a function:
f = aS(Ax) + bC(Bx)
A,B are given constants,
S(x), C(x) are given functions,
a,b are parameters to be found.
Solution:
Let xi be a point where "measurements" are made,
ri = fi - aSi - bCi - residual.
L = riri - we assume summation via equal indices:
L = SUM riri where i=1,...,n.
La = dL/da, Lb=dl/db; we are using d for a sign of partial derivative.
Conditions of minimum are:
La = 0
Lb = 0
Which implies:
riSi = 0
riCi = 0
aSiSi + bCiSi = fiSi
aSiCi + bCiCi = fiCi
Shortcutting following sums
H=SiSi
G=CiCi
K=CiSi
F=fiSi
P=fiCi
will result in following matrix equation:
|| H K || || a || || F ||
|| || * || || = || || (1)
|| K G || || b || || P ||
or correspondingly:
T * Y = Q (1')
where Y is a column of unknown variables a,b.
There are probably a few numerical and analytical ways to solve (1) depending on
choice of points of measurements xi and
character of "experimental data", fi.
I. Standard solution.
Assume determinant(T) is not 0.
d = det(T) = determinant(T) = HG-KK.
The "standard" solution is to invert matrix T.
Y = T-1Q
T-1 = M/d
|| G -K ||
M = || ||
|| -K H ||
MQ = || GF-KP || a = (GF-KP)/d (2)
|| PH-KF ||, or b = (PH-KF)/d
If HG enough close to KK, (3)
then numerical standard solution will have significant loss of accuracy in d
due floating point arithmetic error.
Intuitively,
for random points xi, probability of (3) will be very small, or
for points xi non-correlating with functions C and S in degenerative manner, d will be far from 0.
Notably, "experimental" values of f do not affect accuracy of solution.
Particular case:
f=aSin(Ax)+bCos(Bx)
S(x) = Sin(Ax)
C(x) = Cos(Bx)
Copyright (C) 2008 Konstantin Kirillov, Landkey Computers. All rights reserved.
June 16, 2008.
References: http://en.wikipedia.org/wiki/Least_squares