Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
292 views

Linear Least Square and Euler Method

The document discusses various methods for curve fitting, including the method of least squares. It provides examples of applying the method of least squares to fit straight lines and exponential curves to sets of data points. It also discusses the Euler's method for numerically solving differential equations, providing the general equations and an example problem.

Uploaded by

Shona Pahuja
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
292 views

Linear Least Square and Euler Method

The document discusses various methods for curve fitting, including the method of least squares. It provides examples of applying the method of least squares to fit straight lines and exponential curves to sets of data points. It also discusses the Euler's method for numerically solving differential equations, providing the general equations and an example problem.

Uploaded by

Shona Pahuja
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

DEPARTMENT OF

PHYSICS RTMNU

GUIDED BY: ROSHNI BEESHAM PAHUJA


Dr. P.M. GADE M.Sc I SEM
CURVE FITTING
 The general problem of finding
equation of approximating curves
which fit given set of data is called
CURVE FITTING.
 It involves the determination of
the continuous function y=f(x)
which results in best fit for given
set of values of
(x1,y1),(x2,y2),…,(xn,yn).
 There are various method
available for curve fitting but
method of least square is the
most popular method.
METHOD OF LEAST SQUARE
• The method of least square
is a standard approach to the
approximate solution of
overdetermined systems,
i.e., sets of equations in
which there are more
equations than unknowns.

•"Least squares" means that the overall solution minimizes


the sum of the squares of the errors made in the results of
every single equation.
PRINCIPLE OF LEAST SQUARE
Let y=f(x) be equation of curve to be fitted to given data
points at
A curve is a best fit if the sum of the squares of deviations
of the individual points from the curve is minimum.
Let y= a+bx be the straight line to
given data points.

deviation=yi - f(xi)
R²= ∑(yi-f(xi))² (R=∑deviation)
On simplification of above 2 equations

Above two equation are normal


equations.

Solving them gives the value of a


and b which completes the
equation y=a+bx
Example of a Straight Line

Fit a straight line to the x and y values in the


following Table:
xi yi xi yi xi2
∑ xi = 28 ∑yi = 24 .0
1 0.5 0.5 1
2
2 2.5 5 4 ∑x i =140 ∑ x i y i =119.5
3 2 6 9
4 4 16 16
5 3.5 17.5 25
6 6 36 36
7 5.5 38.5 49

28 24 119.5 140
a1 = n∑ xi yi −
∑ xi ∑ yi
n∑ xi − ( ∑ xi )
2 2

7 ×119.5 − 28 ×24
= = 0.8392857
7 ×140 − 28
2

a 0 = y −a1x
= 3.428571 − 0.8392857 × 4 = 0.07142857

Y = 0.07142857 + 0.8392857 x
Example Of Other Curve
Fit the following Equation:
b
y= a x
b
log y = log(a x )
to the data in the following table:

xi yi X=log x Y=logy i log y = log a + b log x


i
1 0.5 0 -0.301 Let Y = log y, X = log x,
2 1.7 0.301 0.226
3 3.4 a 0 =log a , a = b
0.477 0.534 1
4 5.7 0.602 0.753 Y = a0+ a1 X
5 8.4 0.699 0.922
15 19.7 2.079 2.141
Xi Yi X*i=Log(X) Y*i=Log(Y) X*Y* X*^2

1 0.5 0.0000 -0.3010 0.0000 0.0000

2 1.7 0.3010 0.2304 0.0694 0.0906

3 3.4 0.4771 0.5315 0.2536 0.2276

4 5.7 0.6021 0.7559 0.4551 0.3625

5 8.4 0.6990 0.9243 0.6460 0.4886

Sum 15 19.700 2.079 2.141 1.424 1.169

n ∑xi yi − ∑x ∑ y
i i 5 ×1.424− 2.079 ×2.141 1.75
a1 = = =
n∑ x²i − ( ∑x i ) 2 5 × 1.169 − 2.0792

a0 = y − a1x =0.4282 −1.75 × 0.41584= − 0.334


CURVE FITTING

log y=-0.334+1.75log x

1.75
y = 0.46x
APPLICATIONS AND ADVANTAGES

The most important application is in data fitting.


The best fit in the least-squares sense minimizes
the sum of squared residuals, a residual being the
difference between an observed value and the
fitted value provided by a model.
The graphical method has its drawbacks of being
unable to give a unique curve of fit .It fails to give
us values of unknown constants whereas principle of
Least square provides us with a elegant procedure to
do so.
EULER’S METHOD
The Euler’s method is a technique of developing linear
approximation to the numerical solution of a
differential equation using the initial point and the slope
of the curve at the initial point.
Euler’s Method
Consider following first order
ordinary differential equation

 f  x, y , y 0   y 0
dy
dx

Rise
Slope 
Run
y1  y0

x1  x0
 f  x0 , y 0 

y1  y0  f x0 , y0 x1  x0 

 y0  f x0 , y0 h

Graphical interpretation of the first step of Euler’s method


Euler’s Method

General equations:

yi 1  yi  f xi , yi h

h  xi 1  xi
Example
Question : Apply Euler’s Method to solve y’=x+y .Given
y(0)=0.Find y at x=0.8 using step length 0.2 .

Solution : Given,
y’=x+y , y(0)=0 ,h=0.2
Than using Euler’s Method
yn+1=yn+hf(xn,yn) …………..(1)
Putting n=0, for finding first approximation than we have,
y1=y0+hf(x0,y0)
y1=0+0.2×0 =0
Putting n=1, for finding second approximation than we have,
y2=y1+hf(x1,y1)
Example
y2=0+0.2× 0.2 =0.4
Putting n=2, for finding third approximation than we have,

y3=y2+hf(x2,y2)
y3=0.04+0.2× .44=0.128
Putting n=3, for finding forth approximation than we have,

y4=y3+hf(x3,y3)

y4=0.128+0.2×0.728=0.2736
At y(0.8)=0.2736
ADVANTAGES AND DISADVANTAGES

The main advantage of the Euler method is that it's


one of the most basic numerical method of
numerically integrating ordinary differential
equations.
A downside however is that it can sometimes have a
tendency to be unstable due to round off error and
discretization error unless you take small steps i.e
‘h’ in the algorithm.

You might also like