Engineering Experiments and Function Discovery
In engineering we often make experiments to understand how a system behaves under varying
conditions. These experiments produce a set of data points. The next step in understanding the
system would be to determine a formula ( ) x f y = that represents the behavior of the system.
This process is called “function discovery”. The formula that is discovered is called to be a
“good fit” if it goes close to the data points that are collected from the experiments.
Suppose that we are testing the braking performance of a new car. We run different
experiments with varying speeds and find the stopping distances of the car as:
Speed
(km/h)
Stopping
Distance (m)
20 6.725
40 16.625
60 30.975
80 50.000
100 68.300
120 93.125
140 117.975
When we plot the data, we see how the stopping distance changes with respect to speed. The
next step is to discover a formula that goes through these data points. For instance for this
data set, 07 . 20 9360 . 0 − = x y represents the system as shown in the figure.
The Least Squares Approximation must be used
PART 1:
Write a program that reads in the data points line by line. That is, the user will give the first
pair of x and y values, press enter, give the second pair of x and y values, press enter, and so
on. The user will press -1 for both x and y values to stop entering data.
Your program will find and display the two linear equations in terms of A and B (like
equation 3 above).
PART 2:
Write a new program that reads in the coefficients for two linear equations of two unknowns
and solves them. For instance when the user enters the coefficients in equation 3 as:
56000 560 41179.5
560 7 383.7
Your program will find and display the values of A and B as in equation 4.
ı hae to get the solution until this night if anybody can write the program by using stdio.h library and functions thanks