Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Num_met_workbook.doc
Скачиваний:
0
Добавлен:
21.04.2019
Размер:
904.7 Кб
Скачать

Computer labs

"It is unworthy of excellent persons to lose hours like slaves in the labor of calculation."

  • Gottfried Wilhelm von Leibniz

To the Student

Computers have been part of the landscape for some time now. The proliferation of mathematical software is changing the way that we use mathematics and programming, giving us the freedom to conduct numerical experiments without the drudgery of rote calculation. The payoff is that you'll learn to use a powerful tool, and develop numerical techniques without that would be difficult or impossible with pencil and paper alone.

Every student will do 5 laboratory works:

  1. Numerical Integration.

  2. Solution of linear algebraic equations.

  3. Solution methods of non-linear equations.

  4. Integration of ordinary differential equations.

  5. Interpolation and extrapolation of functions.

In these assignments, you practice writing a few simple programs and compile them into executable programs using Pascal (C++) languages. If necessary, obtain a book (see some of the recommended ones in the SYLLABUS) and\or take a Pascal (C++) tutorial.

Make sure that your program is well commented/documented, structurally sound, aesthetically written, executes smoothly, and yields correct results. Submit both a hardcopy printout of the source code (program and results) and an executable file on a diskette for grading and discussing.

The laboratory tasks Lab 1. Numerical Integration.

Write a program to numerically integrate the following functions:

Variant 1. Numerically integrate the Gaussian function:

with a subroutine of your choice accurate to four significant digits. Test cases: x = 0.5, x = 1. This integral occurs frequently in statistics (e.g., the normal distribution function). Try some test cases to make sure that your answer is correct. Use the trapezoidal rule to determine this integral with different numbers of subintervals.

Variant 2. Evaluate the integral from Var. 1, but use a) Left sum, b) Right sum, and c) Midpoint approximations.

Variant 3. Numerically evaluate the following definite integral accurate to 4 significant digits.

.

Use the Simpson's rule. Try some test cases to make sure that your answer is correct.

Variant 4. Evaluate the integral from Var. 3 using Simple Monte Carlo approximation. Lab 2. Solution of Linear Algebraic Equations.

Write a program to solve a set of linear algebraic equations of the form A·x = b, where A is a matrix of an arbitrary size specified by the user, b is an input vector, and x is the solution.

Variant 1. Given the linear system, where:

Solve this system by Gaussian elimination with back substitution. Substitute your results into the original equations to check your answers.

Variant 2. Solve the linear system from Var. 1 using Jacobi iteration. Check your results.

Variant 3. Solve the linear system from Var. 1 using Gauss - Seidel iteration. Substitute your results back into the original equations to verify your solution.

Variant 4. Given the linear system, where:

Use the Cramer's rule to solve for the x's. Compute the determinants using Gaussian elimination. Substitute your results back into the original equations to verify your solution.

Variant 5. Solve the linear system from Var. 4. Find A-1 using Gaussian elimination with back substitution and finally the solution x. Multiply the inverse by the original coefficient matrix and assess whether the result is close to the identity matrix. Substitute your results back into the original equations to verify your solution.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]