0% found this document useful (0 votes)
35 views

Appendix: How To Use The Excel Solver To Fit Data To Any Equation

The document describes how to use Excel's Solver tool to fit experimental data to equations by minimizing the sum of squared differences between measured and fitted values. It provides a step-by-step example of fitting concentration data over time to an exponential equation. Key steps include: (1) inputting data and initial constant guesses, (2) calculating fitted values, (3) determining differences, (4) minimizing the sum of squares using Solver by varying the constant values. The method can be applied to fit data to any equation by modifying the equation used to calculate fitted values.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Appendix: How To Use The Excel Solver To Fit Data To Any Equation

The document describes how to use Excel's Solver tool to fit experimental data to equations by minimizing the sum of squared differences between measured and fitted values. It provides a step-by-step example of fitting concentration data over time to an exponential equation. Key steps include: (1) inputting data and initial constant guesses, (2) calculating fitted values, (3) determining differences, (4) minimizing the sum of squares using Solver by varying the constant values. The method can be applied to fit data to any equation by modifying the equation used to calculate fitted values.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Appendix: How to Use the Excel Solver to Fit Data to Any Equation

A very handy, but not very well known, feature of Excel is the “Solver”. It is essentially a glorified
version of “Goal seek”. The differences are that you can manipulate more than 1 cell value to
achieve your target value, and you can also perform minimisations and maximisations.
Amongst other things, the Solver can be used for “custom” curve fitting, using the least squares
method. You may already came across the standard curve fitting facility of Excel. However, this
has only a limited range of fitting functions. In this example (taken from the Part A Computing
labs) we will look at fitting data to an exponential increase (as occurs in e.g. the concentration of
a reaction product). You will find that you cannot do this using the standard Excel “exponential”
curve fit. If the equation you want to fit to your experimental data is different to this then don’t
worry – the equation can be easily modified later (once you have seen how the solver works).

We will fit the data on the left to the following equation.


c  A  ( B  A) * exp C * t 
Enter in the following data:
Time Measured
(s) Concentration (i) First make space at the top of the spreadsheet to hold the
(mM) three fitting constants A (final value),B (initial value) and C
(rate constant).
0 0.8
30 2.1 (ii) To get things started enter initial guesses for these values.
60 3.1 (iii) Now create a column next to “Measured Concentration”
90 3.9 and entitle this “Fitted Concentration”.
120 4.5
150 4.9 (iv) This column will contain concentration values calculated
180 5.3 according to the above equation and the values of the
210 5.5 constants A, B and C. Do this now.
240 5.8 (v) Create a 4th column called “Difference squared”. This
270 5.9 column contains the square of the difference between the
300 6.1 “measured concentration” and the “fitted concentration” for
each time.
(vi) Finally sum up the values in this 4th column. This will give
the sum of the squares of the differences.
You should now have a spreadsheet looking something like this:

AGF Stapley 1 Solver 2012


You can see in the example spreadsheet that the 3 constants chosen give a reasonable
approximation, but not a close one - we should be able to do better than this. We now turn to
the solver to achieve a least squares fit by minimising the “sum of squares” cell by adjusting
the values of A, B and C.

(vii) Go to Solver option under the Data menu . If you cannot see you need to import the
feature under Add-ins.
In Excel 2007 click the large Microsoft Office button on left hand side of menu, then click
“Excel Options”, then click “Add-Ins”, then make sure “Excel Add-ins” is selected under
“manage”, then click “Go”, then click “Solver Add-in” followed by “OK”.
In Excel 2010 go to the File menu and select Options instead of clicking the Microsoft Office
button (which doesn’t exist).
For other versions of Excel please refer to the on-line help and you should find it.

(viii) Open the solver. You should make the following settings:
(a) “Set target” should be the sum of squares value (e.g. D23 in the spreadsheet
overleaf)
(b) “Equal to” should be set to “Min” (as we are trying to minimise this value)
(c) “By changing cells” should be the cells containing the constants A,B, and C
(i.e. B3:B5 in the spreadsheet overleaf).
(d) We do not have any constraints on what values A, B, or C can take so just
click “Solve”.
(e) This should produce your fit. If you are happy with the values then click “Keep
Solver Solution” and then “OK”. You have the option of producing some
reports but you don’t generally need these.
(f) Make a plot of your experimental data and fitted equation. The data should be
plotted as symbols only (with no line) and the fitted eqution as a line only (with
no symbols).

This method is general and can be used to fit data to any equation – just type in the
relevant equation in step (iv). The above example has 3 fit parameters, but if you need
to use more or fewer fit constants then change the number you use in step (i) and (viii
c) . (N.B. If fitting more than 3 fit constants, it may not always find the best fit – it can
depend on what initial guesses you provide in step (ii)).

AGF Stapley 2 Solver 2012

You might also like