### PSEUDO-CODE

We present basic pseudo-code for some of the algorithms, discussed in the Steps. In our experience, students do benefit by studying the pseudo-code of a method at the same time as they learn it in a Step. If they are familiar with a programming language, they should attempt to convert at least some of the pseudo-codes into computer programs, and apply them to the set Exercises.### Bisection Method

The equation is*f (x )*= 0.

### Points for study:

- What is the input used for?
- Explain the purpose of Lines 8 - 12.
- Amend the speudo-code, so that the process will always stop after preset
*M*iterations. - Amend the pseudo-code so that the process will stop as soon as
- Write a computer program, based on this speudo-code.
- Use your program to solve Exercises
**1**and**2**in the Applied Exercises.

### Method of False position

The equation is*f (x )*= 0.

### Points for study

- What are the input values used for?
- Under what circumstances may the process stop with a large error in
*x*? - Amend the pseudo-code so that the process will stop after
*M*iterations, if the condition in Line 13 is not satisfied. - Write a computer Program based on the pseudo-code.
- Use your program to solve Exercises
**1**and**2**in the Applied Exercises.

### Newton-Raphson iterative method

The equation is*f (x )*= 0.

### Points for study

- 8
- How are the input values used?
- Why is
*M*given in the output of Line 10? - What happens if
*f'(a)*is very small? - Amend the pseudo-code to take suitable action if
*f'(a)*is very small. - Write a computer program based on the pseudo-code.
- Use your program to solve Exercises
**1**and**2**in the Applied Exercises.

### Gauss Elimination

The system is:
*

### Points for study

- Explain what happens in Lines 2 - 10.
- What process is implemented in Lines 11 - 18`?
- Amend the pseudo-code so that the program terminates with an informative message when a zero pivot element is found.
- Write a program based on the pseudo-code.
- Use your program to solve Exercises
**3**and**4**in the Applied Exercises.

### Gauss-Seidel Iteration

The system is:### Points for study

- What is the purpose of the number
*s*? - What are the
*y*_{1},*y*_{2 1}, . . .,*y*_{n}used for? - Why is it possible to replace the
*y*_{j}in Line 13 by*x*_{j}? - Amend the pseudo-code to allow a maximum of
*M*iterations. - Write a program based on the pseudo-code.
- Use thc computer program to solve the system:
- Use your program to solve Exercises
**3**and**4**in the Applied Exercises

### Newton divided difference formula

You are to calculate for given data*x*

_{0},

*x*

_{1}, . . . ,

*x*

_{n},

*f(x*

_{0}),

*f(x*

_{1}), . . .,

*f(x*

_{n}), and for given the interpolating polynomial

*P*

_{n}

*(x>*of degree

*n*. (The algorithm is based on divided differences.)

### Points for study

- Follow the pseudo-code through with the data
*n*= 2, .*x*= 1.5,*x*_{0}= 0,*f (.x*_{0}) = 2.5,.*x*_{1}= 1,*f (x*_{1}) = 4.7,*x*SS_{2}= 3, and*f x*_{2}) = 3.1. Verify that the values*d*_{ii}calculated are the divided differences*f*(*x*_{0}, . . .,.*x*_{I}). - What quantity (in algebraic terms) is calculated in Lines 10 - 15?
- Amend the pseudo-code so that the values
*P*_{1}(*x*),*P*_{2}(*x*)P&127;(x), . . .,*P*_{n-1}(*x*)are also printed out. - Write a computer program based on the pseudo-code.
- Use your program to estimate
*f*(2) for the data given in**1**above. - For the data, given in Exercise
**6**of the Applied Exercises, use the program to obtain an estimate of*J*_{0}(0.25).

### Trapezoidal Rule

The integral is:### Points for study

- What are the input values used for?
- What value (in algebraic terms) does
*T*have after Line 11? - What is the purpose of Lines 12-17?
- Write a program based on the pseudo-code.
- Apply your program to Exercises
**7**and**8**of the Applied Exercises.

### Gauss integration formula

The integral is:**Gauss two-point formula**.

### Points for study

- What is the purpose of Lines 2 and 3?
- What changes are required to produce an algorithm based on the Gauss three-point formula?
- Write a computer program based on this pseudo-code.
- Use your program to solve Exercises
**7**and**8**of the Applied Exercises. **Runge-Kutta method***y*' =*f (x,y)*and use the usual fourth-order method.

### Points for study

- What are the input values used for?
- How many times is the function
*f*evaluated between Lines 4 and 17? - Amend the pseudo-code for use with the second-order Runge-Kutta method.
- Write a computer program based on the pseudo-code.
- Use the computer program to solve Exercises
**9**and**10**of the Applied Exercises.

## No comments:

## Post a Comment