Starting from:

$29.99

EE25745-1 Exercise 1 Solution



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


More products