0% found this document useful (0 votes)
19 views2 pages

PHC-101 A6

Problem questions for Python (integration, differentiation and its types,etc)

Uploaded by

prankufufug
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

PHC-101 A6

Problem questions for Python (integration, differentiation and its types,etc)

Uploaded by

prankufufug
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PHC-101: Computer Programming

Exercise Problems 6

Solve the following exercises and submit your solutions in a single ipynb file named
Your-Enrollment-No-A6.ipynb. Please separate different exercises by inserting a text cell
and writing Exercise 1, Exercise 2, etc.
1. Write a function to find the root of an equation using the secant method.
2. Using the above code find the root of the following functions. (a) cos(x) − x, (b)
exp(x) − 3, (c) exp(−x) − x.
3. Write a function to find the root of a nonlinear equation using the Newton-Raphson
method.
4. Find the root of the function f (x) = x3 − x − 2 using the Newton-Raphson and the
secant methods. Compare the number of iterations.
5. Write a function to convert a system of linear equations to a lower triangular system.
Use this to determine A, B, C, D in the following system.
A + 2B + 3C + D = 10
2A + 3B + C + 4D = 11
3A + B + 2C + 2D = 13
4A + 2B + 3C + 3D = 15

6. Write a function to solve a system of linear equations using the Gauss-elimination


method. Solve the following system of linear equations.
6A + 2B − 1C − 9D = 75
−6A − 2B − 7C + 0D = −11
4A − B − C + 6D = −51
−4A − 2B + 5C + 6D = −47

7. Create a function to calculate the derivative of the functions using forward difference
method.
8. Using the above code find the derivative of (a) sin(x) exp(x) at x = π/2 (b) tan(x2 )
at x = 3π/4. Use h = 10−1 and h = 10−3 and find the errors in derivatives.
9. Find the derivatives in the above exercise using the backward and central difference
methods. Compare the errors from different methods.
10. Solve dy/dx = x for x ∈ [−4, 4] with y(x = −4) = 8 using the Forward Euler, RK2
and RK4 methods. Plot the curves y(x) found using these methods and compare
with the analytical solution.

11. Write a function to solve a system of differential equations (in two variables) using
the Forward Euler method.

12. Solve the following differential equations using the Forward Euler method.
dy
(a) = y 2 , y(0) = 1
dt
dx
(b) = 5x + 3y, x(0) = 2, y(0) = 1
dt
dy
= 2x + 4y
dt

13. Create a function to determine the coefficients of the Least-Squares line for the set
of data points {xi , yi } = (−2, 1), (−1, 2), (0, 3), (1, 3), (2, 4).

14. Create a function to find the coefficients of a powerlaw y = AxB , which is the best
approximation to the dataset {xi , yi } = (108 , 23.4), (3 × 108 , 31.3), (109 , 42.5), (3 ×
109 , 59.1), (1010 , 80.2). Plot the dataset and the found powerlaw. Use logarithmic
scale for both the axes.

Page 2

You might also like