Activity #2: Taking limits to compute derivatives Write a program named Lab5a_Act2.py to compute a derivative as a numerical limit. This activity has three parts. Please separate the various parts of your code with a comment to identify the separate sections. a) Evaluating a polynomial Write a program that takes as input from the user a set of four (4) coefficients for a cubic polynomial of the form f(x) = Ax² + Bx² + Cx + D Next, take as input from the user a value for x, and evaluate the polynomial at that x.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please help me answer parts b) and c) in python programming. I have attached the screenshot to my code for part a to help :)

import math
print("Enter the coefficients of the form ax^3 + bx^2 + cx + d")
1st=[]
for i in range (0,4):
a=int(input("Enter coefficient:")) # read 4 coefficients A,B,C,D
1st.append(a)
x=int(input(("Enter the value of x:")) # read value of x
suml=0
j=3
for i in range(0,3):
while(j>0):
suml=suml+(1st[i]*math.pow(x,j)) # calculate sum of equation
break
j-j-1
sum1=sum1+lst[3]
print("f(-2,0) is:",sum1
# print
Transcribed Image Text:import math print("Enter the coefficients of the form ax^3 + bx^2 + cx + d") 1st=[] for i in range (0,4): a=int(input("Enter coefficient:")) # read 4 coefficients A,B,C,D 1st.append(a) x=int(input(("Enter the value of x:")) # read value of x suml=0 j=3 for i in range(0,3): while(j>0): suml=suml+(1st[i]*math.pow(x,j)) # calculate sum of equation break j-j-1 sum1=sum1+lst[3] print("f(-2,0) is:",sum1 # print
Activity #2: Taking limits to compute derivatives
Write a program named Lab5a_Act2.py to compute a derivative as a numerical limit. This activity has
three parts. Please separate the various parts of your code with a comment to identify the separate
sections.
a) Evaluating a polynomial
Write a program that takes as input from the user a set of four (4) coefficients for a cubic
polynomial of the form
f(x) = Ax? + Bx + Cx + D
Next, take as input from the user a value for x, and evaluate the polynomial at that x.
b) Evaluating a polynomial limit analytically
In your calculus class, you should have learned by now how to find the derivative of a
polynomial (as another polynomial). If you are struggling with how to find a derivative, ask a
member of the teaching team for help. Add to your program code to compute the derivative of a
polynomial (i.e. compute the three coefficients of the derivative f'(x)) using the same
coefficients and value of x as you used in part a.
c) Evaluating a polynomial derivative numerically
For a function f(x), the numerical derivative of the function at a value x can be found by
evaluating
*+)-f(*) and finding the limit as a gets closer and closer to zero (0). Start by using
a
a value for a of 0.1. Then, divide a by 2 repeatedly until the difference between two successive
evaluations of -
f(x+a)-f(x)
is less than a tolerance of 10*. Use the same polynomial and value of
a
x as you used in part a, and compute the limit numerically. Taking numerical derivatives like this
is commonly done when fun ions are too complicated to evaluate analytically.
Repeat the above numerical erivative by evaluating the limits of the following expressions:
f(x)-f(x-a)
and *+a)-f(x-c
Compute each of these, and output the results using the format
a
2a
shown below. Do you get difi rent results with any of them? Add a comment in your code to
answer the question.
Use six (6) decimal places to print the umerical derivatives.
Example output using 2x + 3x – 1 x- 6 = 0 and x = -2:
Enter the coefficient A: -
Enter the coefficient B: 3
Enter the coefficient C: -11
Enter the coefficient D: -6
Enter a value for x: -2
f(-2.0) is 12.0
f' (-2.0) analytically is 1.0
f' (-2.0) numerically is 0.999999
f'(-2.0) numerically is 1.000001
f'(-2.0) numerically is 1.000000
Transcribed Image Text:Activity #2: Taking limits to compute derivatives Write a program named Lab5a_Act2.py to compute a derivative as a numerical limit. This activity has three parts. Please separate the various parts of your code with a comment to identify the separate sections. a) Evaluating a polynomial Write a program that takes as input from the user a set of four (4) coefficients for a cubic polynomial of the form f(x) = Ax? + Bx + Cx + D Next, take as input from the user a value for x, and evaluate the polynomial at that x. b) Evaluating a polynomial limit analytically In your calculus class, you should have learned by now how to find the derivative of a polynomial (as another polynomial). If you are struggling with how to find a derivative, ask a member of the teaching team for help. Add to your program code to compute the derivative of a polynomial (i.e. compute the three coefficients of the derivative f'(x)) using the same coefficients and value of x as you used in part a. c) Evaluating a polynomial derivative numerically For a function f(x), the numerical derivative of the function at a value x can be found by evaluating *+)-f(*) and finding the limit as a gets closer and closer to zero (0). Start by using a a value for a of 0.1. Then, divide a by 2 repeatedly until the difference between two successive evaluations of - f(x+a)-f(x) is less than a tolerance of 10*. Use the same polynomial and value of a x as you used in part a, and compute the limit numerically. Taking numerical derivatives like this is commonly done when fun ions are too complicated to evaluate analytically. Repeat the above numerical erivative by evaluating the limits of the following expressions: f(x)-f(x-a) and *+a)-f(x-c Compute each of these, and output the results using the format a 2a shown below. Do you get difi rent results with any of them? Add a comment in your code to answer the question. Use six (6) decimal places to print the umerical derivatives. Example output using 2x + 3x – 1 x- 6 = 0 and x = -2: Enter the coefficient A: - Enter the coefficient B: 3 Enter the coefficient C: -11 Enter the coefficient D: -6 Enter a value for x: -2 f(-2.0) is 12.0 f' (-2.0) analytically is 1.0 f' (-2.0) numerically is 0.999999 f'(-2.0) numerically is 1.000001 f'(-2.0) numerically is 1.000000
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY