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

A. Finding Roots of The Equations:: (Algorithm

The document provides 12 numerical analysis problems to implement using Python, including finding roots of equations using bisection and Newton's methods, interpolation using finite differences and Lagrange's formula, numerical integration using trapezoidal and Simpson's rules, solving differential equations using Euler's and Runge-Kutta methods, and curve fitting using least squares to fit linear and exponential models. Students are asked to present results in tables and graphs to demonstrate their understanding of these numerical methods.

Uploaded by

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

A. Finding Roots of The Equations:: (Algorithm

The document provides 12 numerical analysis problems to implement using Python, including finding roots of equations using bisection and Newton's methods, interpolation using finite differences and Lagrange's formula, numerical integration using trapezoidal and Simpson's rules, solving differential equations using Euler's and Runge-Kutta methods, and curve fitting using least squares to fit linear and exponential models. Students are asked to present results in tables and graphs to demonstrate their understanding of these numerical methods.

Uploaded by

Bino
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Kathmandu University

MCSC-202 with Python


Assignmnet-II
Level: CS/CM/ENVE 2nd sem/2nd year Course: Numerical Methods (MCSC-202)
Instructor: Dr. Samir Shrestha

Implement the following problems using Python to get the results.

A. Finding Roots of the Equations: Present each iteration result in a table


1. Implement the Bisection Method to approximate the root of the equation 𝑥 2 = 𝑠𝑖𝑛𝑥 by taking the initial
𝒂+𝒃
guesses 𝑎 = 0.5 𝑎𝑛𝑑 𝑏 = 1.0. (Algorithm: 𝒙𝟎 = )
𝟐

2. Implement the Newton-Raphson’s Method to approximate the root of the equation 𝑒 𝑥 = 4𝑥 by taking
𝒇 𝒙
the initial guess 𝑥0 = 1.0 (Algorithm: 𝒙𝟏 = 𝒙𝟎 − 𝒇′ (𝒙𝟎 ))
𝟎

B. Interpolation
3. Construct the finite difference table of the function 𝑓 𝑥 = 𝑒 𝑥 on the interval −1 ≤ 𝑥 ≤ 1 by
dividing the interval by equally space points of step-size 0.1
4. Estimate the value of the function 𝑓(0.21) and 𝑓(0.29) applying Newton’s forward and
backward interpolation polynomials using following table:
x 0.20 0.22 0.24 0.26 0.28 0.30
y 1.6596 1.6698 1.6804 1.6912 1.7024 1.7139

5. Estimate 𝑦 2 from the following data using Lagrange’s formula

x 0 1 3 4 5
y 0 1 81 256 625

C. Numerical Integration
𝜋 𝑠𝑖𝑛𝑥
6. Implement Trapezoidal-rule to approximate the definite integral 𝐼 = 0 𝑒𝑥
𝑑𝑥 by taking 20-equal
𝒉
divisions of the interval [0, 𝜋]. (Algorithm: 𝑰 = 𝟐 [𝒚𝟎 + 𝟐 𝒚𝟏 + 𝒚𝟐 + ⋯ + 𝒚𝒏−𝟏 + 𝒚𝒏 ])
2
1 4 −𝑥
7. Implement Simpson’s 1/3-rule to approximate the definite integral 𝐼 = 2𝜋 −4
𝑒 2 𝑑𝑥 by taking 50-

𝒉
equal divisions of the interval [−4, 4]. (Algorithm: 𝑰 = 𝟑 [𝒚𝟎 + 𝟒 𝒚𝟏 + 𝒚𝟑 + ⋯ + 𝒚𝒏−𝟏 +

𝟐 𝒚𝟐 + 𝒚𝟒 + ⋯ + 𝒚𝒏−𝟐 + 𝒚𝒏 ])

D. Numerical Differential Equations: Present the solution in a table and graph it.
𝑑𝑦
8. Implement Euler’s method to approximate the solution 𝑦(𝑥) of the differential equation 𝑑𝑥
= 𝑥2 +

𝑥, 𝑦 0 = 1 on the interval [0, 2] by diving it into 20- equal sub-intervals. [Algorithm: 𝒚𝒊+𝟏 = 𝒚𝒊 +
𝒉𝒇(𝒙𝒊 , 𝒚𝒊 )]
9. Implement Runge-Kutta 2nd order method to approximate the solution 𝑦(𝑥) of the differential equation
𝑑𝑦
= 𝑥 2 + 𝑥, 𝑦 0 = 1 on the interval [0, 2] by diving it into 10-equal sub-intervals. [Algorithm:
𝑑𝑥
𝟏
𝒚𝒊+𝟏 = 𝒚𝒊 + 𝟐 𝒌𝟏 + 𝒌𝟐 , 𝒘𝒉𝒆𝒓𝒆 𝒌𝟏 = 𝒉𝒇 𝒙𝟎 , 𝒚𝟎 𝒂𝒏𝒅 𝒌𝟐 = 𝒉𝒇(𝒙𝟎 + 𝒉, 𝒚𝟎 + 𝒌𝟏 ) ]

10. Implement the Boundary valued second order differential equation 𝑦" − 64𝑦′ + 10 = 0 by using finite
different method with boundary conditions 𝑦 0 = 𝑦 1 = 0 and taking the step sizeℎ = 0.1.

E. Curve Fitting

11. Using least square method to fit the straight line 𝑦 = 𝑎0 + 𝑎1 𝑥 to the following data:
x 1 2 3 4 5 6
y 2.4 3.1 3.5 4.2 5.0 6.0
Using this fit estimate the value of 𝑦 at 𝑥 = 2.5
12. Using least square method to fit the curve 𝑦 = 𝑎𝑒 𝑏𝑥 to the following data:
x 2 4 6 8 10
y 4.077 11.084 30.128 81.897 222.62
Using this fit estimate the value of 𝑦 at 𝑥 = 9

You might also like