Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python help , sample terminal session posted below Problem 1. Quadratic Equations A quadratic equation has the form: ax2+bx+c=0 The two solutions (called roots) are

Python help , sample terminal session posted below

image text in transcribedimage text in transcribedimage text in transcribed

Problem 1. Quadratic Equations A quadratic equation has the form: ax2+bx+c=0 The two solutions (called roots) are given by the formula: x1,2=2abb24ac Write a program with a loop that : a) solves quadratic equations with coefficients read from the terminal, b) visualizes the corresponding quadratic function y=ax2+bx+c using the matplotlib.pyplot module (replacing module pylab used in the book). Details: 1. The program consists of a main while loop (an infinite loop) in which the user is prompted to enter values for coefficients a,b, and c. Assume the user types valid float numbers from the terminal. The program converts the input to float type and then uses formula (1) above to compute solutions x1 and x2, as follows: - if b24ac0 then the solutions are distinct and the program displays "two solutions: " followed by the values of x1 and x2. To keep the problem simple we can assume that the user never enters a value for coefficient a that is equal to 0 . To stop the loop and end the program the user just types the ENTER key instead of the string for coefficient a. 2. Within the main loop, after printing the values of the real solutions (if any) to the terminal the program displays the graphic of the quadratic function y=ax2+bx+c using the matplotlib.pyplot module. The chart should use 150 points. - If the function has real roots (one or two) make sure the roots are visible on the chart. E.g. if the roots are 1 and 3 use a domain interval for values x (on the 0x axis) that includes 1 and 3 , like [3,5]. - If the function has no real roots, then center the function domain ( x values) on the function's minimum or maximum value, which is xopt=2ab. - Pick your own approach to select the function's domain while complying with the above requirements. Here is a sample user session on the terminal: (user types CTRL-Z on Windows to enter EOF and finish the program)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis In Microsoft Excel

Authors: Alex Holloway

1st Edition

B0CCCPKTTX, 979-8852388452

More Books

Students also viewed these Databases questions

Question

4 How can you create a better online image for yourself?

Answered: 1 week ago