Description
In the name of God
Department of Electrical Engineering
EE 25745-1 Numerical Computation, Group 1 Fall 1397-98
Computer Exercise 1
Compute and plot the values of this polynomial, using each of the two forms, for 101 equally spaced points in the interval[0.995,1.005], i.e., with a spacing of 0.0001.
Your plot should be scaled so that the values for x and for the polynomial use the full ranges of their respective axes. Can you explain this behavior?
2- Write a program to solve the quadratic equation ππ₯2 + ππ₯ + π = 0 using the standard quadratic formula
βπ Β± βπ2 β 4ππ
π₯ =
2π
Or the alternative formula
2π
π₯ =
βπ β βπ2 β 4ππ
Your program should accept values for the coefficients a, b, and c as input and produce the two roots of the equation as output. Your program should detect when the roots are imaginary, but need not use complex arithmetic explicitly. You should guard against unnecessary overflow, underflow, and cancellation. When should you use each of the two formulas?
Try to make your program robust when given unusual input values. Any root that is within the range of the floating-point system should be computed accurately, even if the other is out of the range.
1
Test your program using the following values for the coefficients:
6 5 -4
6 Γ 1030 5 Γ 1030 β4 Γ 1030
0 1 1
1 β105 1
1 -4 3.999999
a b c
10β30 β1030 1030
3- Implement the bisection, Newton, and secant methods for solving nonlinear equations in one dimension, and test your implementations by finding at least one root for each of the following equations. What termination criterion should you use? What convergence rate is achieved in each case?
a) π₯3 β 2π₯ β 5 = 0
b) πβπ₯ = π₯
c) π₯π ππ(π₯) = 1
d) π₯3 β 3π₯2 + 3π₯ β 1 = 0
2
Reviews
There are no reviews yet.