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

Curve Fitting

This document discusses linear curve fitting using the least squares method. It explains that curve fitting finds the best fit line for a set of data points by determining the parameters a and b for the linear equation y = a + bx. The least squares method minimizes the sum of the squared errors by calculating the values of a and b. An algorithm and Fortran code is provided to implement the linear curve fitting. Examples of applications include instrument calibration and determining physical constants from experimental data.

Uploaded by

Sanoj Kushwaha
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Curve Fitting

This document discusses linear curve fitting using the least squares method. It explains that curve fitting finds the best fit line for a set of data points by determining the parameters a and b for the linear equation y = a + bx. The least squares method minimizes the sum of the squared errors by calculating the values of a and b. An algorithm and Fortran code is provided to implement the linear curve fitting. Examples of applications include instrument calibration and determining physical constants from experimental data.

Uploaded by

Sanoj Kushwaha
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Linear curve fitting

By
Sanoj kushwaha
Sachin kumar
Curve fitting
 Curve fitting is the process of finding the curve parameters
that produce the “best fit” line or curve for a series of data
points.

 By the curve fitting we can mathematically construct the


functional relationship between observed facts and
parameter values and used to find unknowns points
anywhere along the fitted curve.
Now, a linear curve is represented by the equation
y = a + bx

Given a set of n data points


(x1, y1) , (x2, y2) ,……… ., (xn; yn)

Now,the question is
what values of ‘a’ & ‘b’
will give us the best fit
line for our data?
Least squares method:
 The method of least squares is a standard approach to
approximate the curve parameters.

 "Least squares" means that the overall solution minimizes the


sum of the squares of the errors made in the results of every single
equation.

The most important application is in data fitting. The best fit in


the least-squares sense minimizes the sum of squared
residuals(errors), a residual being the difference between an
observed value and the fitted value provided by an experiment.
Criteria for a “Best fit “ line :-
The error(E i) at x = x i is given as

.…(1)

From equation (2) and ( 3 ) ,we get


Where ∑
andand represents the
sum from 1 to
n.
Algorithm
1. Start the program.
2. Use implicit none to disable the already declared variables.
3. Define the variables with required data types.
4. Ask user to enter no. of data pair points (n) by using read syntax.
5. Initialise summation:
sum_x = 0
sum_y = 0
sum_xy = 0
sum_xx = 0
6. Ask user to enter the coordinates of x and y.
7. Use do loop to update the sum as:
sum_x = sum_x + x(i)
sum_y = sum_y + y(i)
sum_xy = sum_xy + x(i)*y(i)
sum_xx = sum_xx + x(i)2
8. Using the formula from Least Square method, declare:
b = (n*sum_xy - sum_x*sum_y)/(n*sum_xx - (sum_x)**2)
a= (sum_y – b* sum_x)/n

9. Print values of a and b for y = a + bx.


10. End program.
Fortran code for linear curve fitting
Result:-
Application of curve fitting :-

Fitted curve can be used for predicting unknown value of


data , visualising the data trend and understanding the
relationship between variable .

 In Physics
1. Calibrations of Instruments:

Linear fits are employed in calibrating instruments.


By plotting known input values against instrument
readings, a linear fit can establish a calibration curve,
facilating accurate measurements.
2. Determining Physical constants:
In radioactive decay, experimental data often follows an
exponential decay model. Taking the natural logarithm of the data
can linearize the relationship, allowing for the dertermination of
decay constants.
THANK YOU

You might also like