İzmir Kâtip Çelebi University
Department of Engineering Sciences
IKC-MH.55
Scientific Computing with Python
Take-home Final Examination
January 19, 2024 14:00 January 24, 2024 23:59
Good Luck!
NAME-SURNAME:
SIGNATURE:
ID:
DEPARTMENT:
DURATION: Due to Ja nuary 24, 2024
Answer at least 1 question from each
parts and at most 4 questions.
Prepare your r eport/codes.
Copy your files into a directory named
as your ID.
Upload a single file by c ompressing
this directory to UBYS.
Question Grade Out of
1 25
2 25
3 25
4 25
TOTAL
This page is intentionally left blank. Use the space if needed.
Part I
Numerical Techniques:
Differential Equations - Boundary
Value & Eigenvalue Problems
Choose only two questions.
A) Compute the following boundary value problems with the boundary
conditions given next to them, and Wr ite a program t ha t compares it
to analytical solutions:
y
′′
xy
+ y = x
2
with y(0) = 2, & y(1 ) = 1,
y
′′
= (y
)
2
y + lnx with y(1) = 0, & y(2) = ln2
The analytical solutions of these equations are:
y(x) = 1 + 2
e
2x
e
x
e
2
e
y(x) = lnx
B) Write a program that solve the following eigenvalue problems with the
given boundary conditions a nd find the smallest two eigenvalues:
y
′′
3y
+ 2k
2
y = 0 with y(0) = 0, y( 1) = 0,
y
′′
+ k
2
x
2
y = 0 with y(0) = 0, y( 1) = 0
C) Pöschl-Teller potential It is a widely used po t ential function used
for matter diffusion in modern optoelectronic devices:
V (x) =
¯h
2
2m
α
2
cosh
2
αx
Where, α is a parameter that defines both the intensity and range of
the potential together. It would be α = 0.05 for typical devices. Take
the constants in the Schdinger equation ¯h/2m = 7.62 eV Å
2
. Write
a program to find the ground state energy by solving the Schrödinger
equation with the bo undary conditions ψ(0) = ψ(100) = 0 in the in-
terval x : [0, 100 Å].
1
Part II
Numerical Techniques: Linear
Algebra and Matrix Computing
Choose only one question.
A) Write a program that solves the following systems of linear equations
using Gaussian elimination:
x
1
+ x
2
+ x
4
= 2
2x
1
+ x
2
x
3
+ x
4
= 1
4x
1
x
2
2x
3
+ 2x
4
= 0
3x
1
x
2
x
3
+ 2x
4
= 3
4x
1
+ 8x
2
+ 4x
3
= 8
x
1
+ 5x
2
+ 4x
3
3x
4
= 4
x
1
+ 4x
2
+ 7x
3
+ 2x
4
= 10
x
1
+ 3x
2
2x
4
= 4
B) Write a program that first checks that the determinants of the matrices
given below are as being nonzero and t hen calculates their inverses.
(There is a simple way to check yo ur results: Multiply each matrix by
its inverse and it should result as a unit matrix.)
3 2 1
0 1 4
6 3 2
1 0 2 3
3 1 1 4
1 0 2 1
4 3 6 0
C) Set up a system of equations that give the currents with Kirchhoff’s
rules for t he direct current circuit given in the figure and write a pro-
gram that calculates these currents.
2
Part III
Data Analysis: Interpolation and
Curve Fitting
Choose only one question.
A) Bessel functions cannot be expressed in terms of known functions, but
are defined as a series of infinite terms as follows:
J
n
(x) =
X
k=0
=
(1)
k
k!(n + k)!
x
2
n+2k
The values of J
0
(x) in the range of [0,3] are given in the t able below:
x J
0
(x)
0.0 1.00000000
0.5 0.93846981
1.0 0.76519769
1.5 0.51182767
2.0 0.22389078
2.5 0.04838378
3.0 0.26005195
Write a python program that establishes the Lagrange interpolation for
Bessel functions at these 7 points and interpolate at x = 1.7 5 and x =
2.99, then compare them with their exact values (J
0
(1.75) = 0.36903253
ve J
0
(2.99) = 0.25664274). Which value would be more inaccurate?
Explain.
B) The volume variation of a liquid with the temperature is given in the
table below:
V (cm
3
) T (
C)
1.032 10.0
1.094 29.5
1.156 50.0
1.215 69.5
1.273 90.0
Write a python program to find the coefficients a and b by assuming
that this liquid volume va ries with the relation V = 1 + aT + bT
2
.
3
C) For the given data points;
x Y
0.000 1.500
0.142 1.495
0.285 1.040
0.428 0.821
0.571 1.003
0.714 0.821
0.857 0.442
1.000 0.552
to which we will fit y(x) = αe
βx
.
First, we should compute a new table with z(x) = lny(x)
Construct the no r mal equations for z = A + Cx where A = l
and C = β
Solve these normal equations t o find A and C
Convert back to the original variables
Plot Y vs x and y vs x then compare them.
4