Assignment #3 - 90A

# Assignment #3 - 90A

```                            ASSIGNMENT 3
DUE DATE Feb 6 90                (WEIGHT 25)

WRITE A PROGRAM TO FIND THE  LEAST SQUARES FIT TO A SET OF
DATA ACCORDING TO THE EXPRESSION GIVEN BELOW.

Y(1), Y(2), Y(3),  ...  ,  Y(N) ARE  READINGS  THAT  VARY  WITH
THE VALUES X(1), X(2), X(3), ... , X(N) OF AN INDEPENDENT
VARIABLE X.

EACH PAIR OF VALUES, (X AND Y) ARE CONTAINED ON ONE CARD. THE
DATA SET IS TERMINATED BY A "DUMMY LINE" WITH X AND Y BOTH
NEGATIVE.

THE EQUATION OF A STRAIGHT LINE IS
Y = AX + B
AND THE BEST STRAIGHT LINE FOR THE GIVEN DATA IS GIVEN BY

N*SXY - SX*SY
A  =  -------------
N*SX2 - SX*SX

SY*SX2 - SX*SXY
B  =  ---------------
N*SX2 - SX*SX

N     NUMBER OF (X,Y) PAIRS
SX    SUM OF X'S
SY    SUM OF Y'S
SX2   SUM OF X*X'S
SXY   SUM OF X*Y'S

DRAW A PENCIL SKETCH ON YOUR OUTPUT SHOWING THE INPUT DATA AND THE
LEAST SQUARES FIT LINE. YOUR PROGRAM SHOULD PROCESS TWO SETS OF
DATA, THE ONE GIVEN BELOW AND A SET OF YOUR OWN.

SAMPLE DATA:
2.8       8.0
7.0       1.5
3.8       7.2
0.2      12.1
2.0      10.5
4.0       6.0
6.1       3.6
6.9       3.6
7.6       2.2
4.1       5.0
5.3       5.0
4.0       8.5
-1.0      -1.0

Note: This program can be done either using ARRAYS or without them,
For five extra bonus marks, do hand in BOTH!
```