Hi Bernard. Thank you very much for the info. :>)
I might be wrong, but here are some thought on the issue.
My experience is that Solver would not work very well here for the
following reasons. With multiple Cos() functions, any plot would show
numerous peaks and valleys. Solver uses Finite differences for a
derivative, and would most likely lock on to a "Local" minimum. Solver
really has no way of telling if it's a Global minimum (or maximum).
When multiple cells are squared, it has no idea what's going on.
For example, both -3 and +3 return 9 (squared). It can't really use this
info to determine a next step. Plus, all the squared terms are fighting
each other in opposite directions.
I might be wrong, but I re-read the problem and "think" I understand what
the op is trying to do.
Just guessing of course...
I believe this is his Cosine Matrix...(Note: Cos(0) -> 1)
I'll just work with 4 points for now...
m = {1, Cos[10], Cos[20], Cos[30]},
{1, Cos[30], Cos[60], Cos[90]},
{1, Cos[50], Cos[100], Cos[150]},
{1, Cos[70], Cos[140], Cos[210]}
Coefficients:
coef = {a0, a1, a2, a3};
Right-hand side data:
rhs = {0.87, 0.8, 1, 1};
Then I think the op is trying to solve the following equations:
m.coef == rhs
{a0 + a1 Cos[10] + a2 Cos[20] + a3 Cos[30] = 0.87,
a0 + a1 Cos[30] + a2 Cos[60] + a3 Cos[90] = 0.8,
a0 + a1 Cos[50] + a2 Cos[100] + a3 Cos[150] = 1,
a0 + a1 Cos[70] + a2 Cos[140] + a3 Cos[210] = 1}
If we expand the Matrix out to 18*18, then the solution should not be a
problem.
My guess is that the op forgot to mention that the numbers are in Degrees!
If those are in degrees, then the Matrix is Singular (ie the Determinant
is zero).
This might account for the problems mentioned.
If they are not in degrees, then Solving the 18 equations in 18 unknowns
yields the following coefficients...
0.80840394,
-0.13310907,
-0.050053729,
-0.028541588,
0.031492505,
0.046523792,
0.0084226285,
0.0804206,
-0.04478755,
-0.054984442,
-0.031472364,
-0.10809329,
-0.087294611,
-0.039289436,
-0.01470285,
-0.023693654,
-0.0030566841,
-0.1441084
Again, I'm just guessing here.
= = =
Dana DeLouis
Bernard said:
Hi Dana,
I took this to be a simple curve fitting exercise
In A2:A19 the values 10, 30, 50, 70 etc
In B2:B19 the values 0.87, 0.8, 1, 1, etc
We return to column C soon
In E1:E10 the next: coeff0, coeff1,....coeff10
In F1:F10 the value 1 in each cell
Select E1:F10 and create names for the F values
In C1 the formula
=coeff0+coeff1*COS(A2)+coeff2*COS(A2*2)+coeff3*COS(A2*3)+coeff4*COS(A2*4)+coeff5*COS(A2*5)+coeff6*COS(A2*6)+coeff7*COS(A2*7)+coeff8*COS(A2*8)+coeff9*COS(A2*9)+coeff10*COS(A2*10)
Copy down the column
In H1 the formula =SUMXMY2(B2:B19,C2:C19) to compute the sum of squares
of deviations
Solver: minimize H1 by changing the coeff values
The ssd is too high - a plot of shows only a fair degree of agreement
between data in B with that in C. Might need to add more coeff
I feel a little awkward telling you how to do something - your math
skills far exceed those a chemist
best wishes