Computer Oriented Numerical Methods
Computer Oriented Numerical Methods
Experiments
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:
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.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.
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.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
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: