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

Computer Oriented Numerical Methods

This document outlines 13 experiments for a course on computer oriented numerical methods. The experiments cover topics like Python programming basics, numerical methods like interpolation, integration, solving differential equations, and partial differential equations. Code examples are provided for each experiment to solve problems related to the covered numerical methods.

Uploaded by

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

Computer Oriented Numerical Methods

This document outlines 13 experiments for a course on computer oriented numerical methods. The experiments cover topics like Python programming basics, numerical methods like interpolation, integration, solving differential equations, and partial differential equations. Code examples are provided for each experiment to solve problems related to the covered numerical methods.

Uploaded by

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

Lab Manual

Course Code: MCC538


Couse Name: Computer Oriented Numerical Methods

Objective: To provide knowledge for implementation of Numerical Methods in Python programming.

Experiments

Exp.No.1: Basics of Python programming, Implementation of read/write files, Python Functions


and Module.
Aim: To write functions and modules with inbuilt libraries.
Numerical producers:
Step-1: Use Mathematical Functions, reading input, printing output, opening and closing of files, reading
writing data to and from file.
Step-2: Write functions and modules.
Output: As per the use functions/modules/read or write file.
Example-1: To make an program to create data file and again read that data file and plot/print data.
Example-2: To make a .txt file of 100 random numbers between two points.

Exp.No.2: Python program for Newton’s forward formula and central Difference Interpolation
Formulae.
Aim: Find the value of a function at an intermediate point.
Numerical producers:
Step-1: The first stage of cubic spline interpolation is to set up equation and solve them for the unknown k0 s.
This task is carried out by the function curvatures.
Step-2: The second stage is the computation of the interpolation at x. This step can be repeated any number
of times with different values of x using the function evalSpline.
Output: As per the program we get intermediate point value.

Example-1: Find the value of sin(52) using Newton’s forward formula. The data table is given below:

θ 45◦ 50◦ 55◦ 60◦


sin(θ ) 0.7071 0.7660 0.8192 0.8660

Example-2: Find the value of f (28) using central difference interpolation formula. The data table is gi-
ven below:

θ 20 25 30 35 40
f (θ ) 49225 48316 47236 45926 44306

1
Exp.No.3: Python program for Adaptive Integration.
Aim: How to take adaptive step size(h) in an integration method.
Numerical producers:
Step-1: Set the tolerance for integration method.
Step-2: If error is grater then tolerance then take step size(h) is half of step size(h).
Step-3: If error is less then tolerance then take step size(h) is double of step size(h).
Output: It is a part of integration method which use for time efficiency and less computation efforts.
Example: Find the solution of given system of ODE using any of the IVP integration method with adaptive
step size:

ẋ = σ (y − x)
ẏ = x(ρ − z) − y
ż = xy − β z
[x0 , y0 , z0 ] = [1, 1, 1]
[σ , ρ, β ] = [10, 28, 8/3]
time = 0 to 40

Exp.No.4: Python program for Gaussian Quadrature.


Aim: Find integration of simple algebraic function using Gaussian Quadrature.
Numerical producers:
n
Step-1: I = ∑ Ai f (xi ) is known as Newton-Cotes rules. The difference lies in the way that the weights Ai
i=0
and nodal abscissas xi are determined.
Step-2: In Gaussian quadrature the nodes and weights are chosen so that above equation yields the exact
integral if f (x) is a polynomial of degree 2n + 1 or less.
Output: We get the integration of given simple algebraic function
5
Example: Evaluate 3 − 11(1 − x2 ) 2 dx as accurately as possible with Gaussian integration.

Exp.No.5: Python program for Multiple Integrals and Solution of Integral Equations.
Aim: Find multiple integral of a function.
Numerical producers:
Step-1: Take a required function for integration.
Step-2: Write a program for multiple integration or using python libraries.
Output: Solution of required function after multiple integration.
Example: Find the value of (x3 + y2 + xy)dx dy.
RR

2
Exp.No.6: Python program for Numerical Solution of linear Equations.
Aim: To solve n linear, algebraic equations in n unknowns using Python.
Numerical producers:
Step-1: Take n linear, algebraic equations in n unknowns.
Step-2: Select Direct or Indirect Method.
Step-3: Using function, and required libraries write program.
Output: Solution of required function after multiple integration.
Example: Find the solution of x − 6y + z = 0; 3x + 2z = 0; 2x + 9y = 0.

Exp.No.7: Python program for Solution of Non-linear Equations.


Aim: To solve required Non-linear Equations i.e. calculate the values of x and y so that f1 (x, y) = 0 and
f2 (x, y) = 0.
Numerical producers:
Step-1: Take a required Non-linear Equations.
Step-2: Using function and required libraries write program.
Step-3: Solve by proper algorithm.
Output: Output gives us the required solution of Non-linear Equations.
Example: Find the root of the given non-linear equation up to four decimal place accuracy by the method of
Newton-Raphson method.

f1 (x, y) = x + xy − 4
f2 (x, y) = x + y − 3

Exp.No.8: Python program Solution of Ordinary Differential Equations using Explicit Runge-
Kutta Methods.
Aim: Find the solution of Ordinary Differential Equations using Explicit Runge-Kutta Methods.
Numerical producers:
Step-1: Take a required Ordinary Differential Equation.
Step-2: Using function and required libraries (scipy) solve the problem.
Output: Output gives us the required solution of Ordinary Differential Equation.
Example-1: Integrate the ODE by fourth-order Runge-Kutta method

δy
= 3y − 4ex − x : y(0) = 1
δx
from x = 0 to 10 in steps of h = 0.1.

3
Exp.No.9: Python program Solution of Ordinary Differential Equations using Explicit Runge-
Kutta with Adaptive Step Size.
Aim: Find the solution of Ordinary Differential Equations using Explicit Runge-Kutta Methods with Adap-
tive Step Size.
Numerical producers:
Step-1: Take a required Ordinary Differential Equation.
Step-2: Using function and required libraries (scipy) solve the problem.
Output: Output gives required solution of Ordinary Differential Equation with Adaptive Step Size.
Example: Integrate the given equation

ÿ + 2ẏ + 3y = 0; y(0) = 0; ẏ(0) = 2

with the adaptive Runge-Kutta method from x = 0 to 5 (the analytical solution is y = e sin 2x).

Exp. No.10: Python program for Multi-step methods, Extrapolation methods.


Aim: Solving polynomial or ODE Multi-step Methods, Extrapolation methods.
Numerical producers:
Step-1: Take a required polynomial.
Step-2: Using function and required libraries solve polynomial by Multi-step Methods and Extrapolation
methods.
Output: Output gives required solution of polynomial.
Example-1: Compute the solution of the initial value problem ẏ = sin y : y(0) = 1 at x = 0.5 with the midpoint
formulas using n = 2 and n = 4, followed by Richardson extrapolation.

Exp. No.11: Python program for Shooting Method, Boundary value problems.
Aim: Solving Boundary value problems.
Numerical producers:
Step-1: Take a Boundary value problems.
Step-2: Using function and required libraries solve Boundary value problem by Shooting Method.
Output: Output gives required solution of Boundary value problem.
Example: Solve differential equation by BVP Method

y000 + 2y00 + sin(y) = 0


y(−1) = 0; y0 (−1) = −1; y0 (1) = 1

4
Exp. No.12: Python program for Numerical Solutions of Partial Differential Equations (PDEs).
Aim Take a Boundary value problems.
Numerical producers:
Step-1: Take a Boundary value problems.
Step-2: Using function and required libraries solve Partial Differential Equations
Output: Output gives required solution of Partial Differential Equations (PDEs).
Example: Solve Laplace equation,

∂ 2u ∂ 2u
+ =0
∂ 2x ∂ 2y
where, u(x, y) defined on x ∈ [0, 1], y ∈ [0, 1] with the boundary conditions
u(x, 0) = 1, u(x, 1) = 2, u(0, y) = 1, u(0, y) = 2.

Lab Exam.13:

You might also like