This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: OPTI 280 Assignment 6 Spring 2010 Due Date: 3/8/2010, 1:00 PM Each assignment is worth 100 points. Assignments that are handed in late will be penalized 15 points per week. NOTE: To receive full credit for any problem, you must hand in printouts of all programs you are asked to write as well as printouts of all command window output and any plots that the programs produce. All programs must conform to the programming rules handed out at the beginning of the semester. Write the answers to the question(s) associated with each problem at the end of the script or function file for that problem (on the same sheet, if possible). Read sections 24 and 25 in the MatLab Tutorial and Chapter 5 in the textbook (Herniter) to get an overview of the new material covered in this assignment. 1. Write a MatLab program that solves the general quadratic equation ax 2 + bx + c = 0 with real coefficients a , b , and c that are entered by the user. The solutions of a quadratic equation can be found by first computing the discriminant: = b 2- 4 ac . If > 0, the quadratic equation has two real roots, given by x 1 =- b + 2 a x 2 =- b- 2 a If < 0, the quadratic equation has two complex roots that are conjugate of one another, given by x i, 1 =- b + i p | | 2 a x i, 2 =- b- i p | | 2 a Your program must also be able to handle and print out solutions for a few special cases: i. If = 0, you can technically use the solutions for the case > 0, but you will find that the two real roots are in fact identical. The solution is said to be a double root and is given by x =- b 2 a . Make sure your program returns that solution once rather than twice!...
View Full Document
This note was uploaded on 05/23/2010 for the course OPTI 280 taught by Professor Pau during the Spring '10 term at University of Arizona- Tucson.
- Spring '10