Complete the following steps: Define a function called polys that takes 4 arguments x, a, b, and c and returns the value of a polynomial of the form ax3 + bx2 + cx. Next, prompt the user to enter the coefficients of the polynomial (see testing input below). Initialize x and assign initial values to variables named max_y and min_y by calling the function polysand passing the initial value of x and the user's input. Calculate the maximum and minimum values and their corresponding x-values over the interval [0, 20]. To accomplish this, create a while loop or a for loop to iterate over the values x = 0.1, 0.2, ..., 19.9, 20 and evaluate the function at each of these x-values (by calling polys) to determine the maximum and minimum function values. Create two formatted print statements that round the values to 2 decimal places and display the output shown below. Sample input and output are shown here Your input should look like this: Enter the coefficient of x^3: 1 Enter the coefficient of x^2: -17 Enter the coefficient of x: 72 Your output should look like this: The maximum value is 2581.23 when x is 19.90. The minimum value is -2.12 when x is 8.50. Complete the following todo's & use comments to explain the steps: # TODO: Define the function 'polys' with arguments x, a, b, and c that returns the value of the polynomial. # TODO: Prompt the user to enter each of the three coefficients using the wording shown above. # TODO: Initialize the value of x and initialize 'max_y' and 'min_y' accordingly by calling the 'polys' function. # TODO: Create a while loop or a for loop to evaluate the 'polys' function at each of the x-values in steps of 0.1. # Your loop should also determine the maximum and minimum function values and the corresponding x-values. # TODO: Create a formatted print statement to print the maximum function value and the corresponding x-value # TODO: Create a formatted print statement to print the minimum function value and the corresponding x-value.
Complete the following steps:
- Define a function called polys that takes 4 arguments x, a, b, and c and returns the value of a polynomial of the form ax3 + bx2 + cx.
- Next, prompt the user to enter the coefficients of the polynomial (see testing input below).
- Initialize x and assign initial values to variables named max_y and min_y by calling the function polysand passing the initial value of x and the user's input.
- Calculate the maximum and minimum values and their corresponding x-values over the interval [0, 20]. To accomplish this, create a while loop or a for loop to iterate over the values x = 0.1, 0.2, ..., 19.9, 20 and evaluate the function at each of these x-values (by calling polys) to determine the maximum and minimum function values.
- Create two formatted print statements that round the values to 2 decimal places and display the output shown below.
Sample input and output are shown here
Your input should look like this:
Enter the coefficient of x^3: 1
Enter the coefficient of x^2: -17
Enter the coefficient of x: 72
Your output should look like this:
The maximum value is 2581.23 when x is 19.90.
The minimum value is -2.12 when x is 8.50.
Complete the following todo's & use comments to explain the steps:
# TODO: Define the function 'polys' with arguments x, a, b, and c that returns the value of the polynomial.
# TODO: Prompt the user to enter each of the three coefficients using the wording shown above.
# TODO: Initialize the value of x and initialize 'max_y' and 'min_y' accordingly by calling the 'polys' function.
# TODO: Create a while loop or a for loop to evaluate the 'polys' function at each of the x-values in steps of 0.1.
# Your loop should also determine the maximum and minimum function values and the corresponding x-values.
# TODO: Create a formatted print statement to print the maximum function value and the corresponding x-value
# TODO: Create a formatted print statement to print the minimum function value and the corresponding x-value.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images