Experiment:: Graphing and Curve Fitting

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Experiment: Graphing and curve fitting

Ateneo de Davao University – Physics Virtual Lab


Objective: Gain a facility in graphing and curve fitting
Equipment: Programs CURV-FIT.EXE
Collections of data may be presented in various forms. The telephone directory is
a simple listing, joining a name/address with a phone number. The multiplication table is
a rectangular array associating a single value to a pair of other values displayed across
the top and left edge of the display. Other data is more conveniently displayed as a
graph, such as the price of rice or the Peso-Dollar exchange rate over a given period of
time. Data from many of the experiments in Physics are best displayed by a graph.
Graphs in Analytic Geometry normally have four “quadrants”: above or below the
horizontal, left or right of the vertical axes. Most graphs in Physics use a single
“quadrant”; Above the horizontal and to the right of the vertical axes. Numerical scales
are placed along each axis. Numbers along the horizontal axis represent distances
measured to the right of the vertical axis. Likewise, numbers along the vertical axis
measure distances above the horizontal axis. A data item associates two quantities,
such as room temperature and time of day. On the graph, a single point represents this
data item; distance from the vertical axis proportional to time of day, distance above
the horizontal axis proportional to room temperature.
Each axis must always have three elements. (1) Label : are horizontal distances
temperature or time? (2) Numbers: the data to be displayed is numerical (not just “cool”
or “warm”, not just “early” or “late”), so
numerical values must be indicated of both
axes. (3) Units: do the numbers on the time
axis represent hours, minutes or seconds.
Graph points represent data items.
But how big is a point? In Math points have
no dimensions, but you draw your points big
enough to easily distinguishable from any
accidental spider droppings nearby, but not
as big as an ink-blot.
What about the range of numbers
along any axis? The numbers should be
equally spaced. They need not start from
zero. Rather, examine first the range of data
values along each axis, and from this, select
the appropriate range values, so that, as far
as possible, your points cover most of the
graph area. Graphs are more easily
constructed and read if the numerals are
multiples of 2, 5 or 10.

Graphing and curve fitting 1


The sample (wrong) graph shows temperature and time. Notice that for each
time value, there is only one temperature, while the same temperature may occur at two
or more different times (perhaps both morning and late afternoon). Here time is said to
be the independent variable, temperature the dependent. Normally the independent
variable is placed along the horizontal axis. Actually the temperature had a definite
value at every moment during the day, even though we have no data pairs for this.
Often a smooth curved line (temperature does not change abruptly during the day) is
drawn on the graph representing our “best guess” for the actual values. Do NOT
connect the points with short straight lines!

Curve fitting
If we expect a linear relationship between the x and y coordinates of N points,
but admit that our measurements may not be too accurate, we might try to sketch a
“best fit” straight line passing as close as possible to each point. Let the equation of
the supposed line be y = Ax + B, where A and B are constants, the slope and y-
intercept respectively. For any given point, [xj,yj] , its displacement is the vertical
distance between the point and the “best fit” line: yj – (Axj + B). This may be positive
or negative, as the point is above or below the line. For “best fit”, the sum of the
absolute value or of the square of these displacements should be a minimum.

Sum of square of each displacement = [yj –(Axj + B)]2


(1)
The mean square displacement is the sum, given by (1), divided by N, the number of
points. The root-mean-square displacement, also called the standard deviation, is
just the square root of the mean square displacement and is a measure of the spread of
points about the “best fit” line. Of course the standard deviation depends on our choice
of A and B.
To find the magic A and B, the first step is the expand the mean square
displacement expression ( Eq. 1 divided by N):

M.S.D. = (yj2 - 2A(xj yj ) - 2Byj + A2xj2 + 2ABxj + B2) / N (2)


Notice that xj / N is the average of the x-coordinates, (xj yj ) / N is the average of the
products of the products of each coordinate pair (Careful! it’s the average of the
products, NOT the product of the averages). In what follows, we express the average of
a quantity by { } rather than by a bar above. Thus {x} stands for xj / N . With this
notation we rewrite (2) as:
M.S.D. = {y2} – 2A{xy} – 2B{y} + A2{x2} + 2AB{x} + B2 (3)
The M.S.D. expression is a function of the two unknown quantities, A and B, for all the
averages are already determined by the given coordinate pairs. So, what values of A
and B will make M.S.D. a minimum? This is a Calculus problem for maxima and minima
of a function of two variables. Set to zero the partial derivative with respect to A and B .
(M.S.D.)/A = 2A{x2} + 2B{x} – 2{xy} = 0 (4a)

Graphing and curve fitting 2


(M.S.D.)/B = 2B + 2A{x} – 2{y} = 0 (5a)
This is just a pair of linear simultaneous equations which may be easily solved for A and
B.
{x2} A + {x} B = {xy} (4b)
{x} A + B = {y} (5b)

A = ( {x}{y} – {xy} ) / ( {x}2 – {x2} )


(7)
B = ( {x}{xy} – {x2}{y} ) / ( {x}2 – {x2} )
(8)
Notice both expressions have the same denominator, the difference between the
square of the average and the average of the squares.

To find the standard deviation, substitute these A and B values into (3) and take the
square root.

Std. Dev. = [ {y2} – 2A{xy} – 2B{y} + A2{x2} + 2AB{x}+ B2 ]1/2

Procedure:
1. Use the computer program CURV-FIT.EXE to generate your personal set of 10
data points, based on your own birthday. Print these of copy them from the
screen display.
2. Graph these points manually on a graphing paper (DO NOT copy the graph
generated by the computer.).
3. Make your own table (refer to the given table in page 4) in the same sheet as
your graph or a separate one and input your [x,y] data values.
4. With a calculator, fill in values for all the remaining table locations, DO NOT
COPY THE GENERATED COMPUTER VALUES. Next find the A and B values.
Use these values to draw the “best fit” straight line. Also find the Standard
Deviation (Std. Dev.) value.
5. Your manual graph, accomplished table (hand-written), a screenshot of the
generated computer values and graph must all be presented in III. Data and
Results of your lab report (all pasted as images). 6. Submit your final laboratory
report as a pdf file.

Graphing and curve fitting 3


item x(time) y(distance) x2 y2 xy
1
2
3
4
5
6
7
8
9
10
sum
average
{x} {y} {x2} {y2} {xy}

A = __________ B = ___________ Std.Dev. = _________

Graphing and curve fitting 4

You might also like