Question
python
b) Evaluating a polynomial derivative numerically For a function f(x), the derivative of the function at a value x can be fou

the polynomial equation is Ax^3+Bx^2+Cx+D
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#### while pasting indentations/tabs may get disturbed, please refer pic for correcttabs

##below is f(x)
def f_x(a,b,c,d,x):
return a*x**3+b*x**2+c*x+d;
  
def derivative_at_x(a,b,c,d,x):
a1=0.1;prev_d=1;d=0;ite=0
while(True):
ite=ite+1
d=(f_x(a,b,c,d,x+a1)-f_x(a,b,c,d,x))/a1;
#print(d)
diff=d-prev_d
prev_d=d
if(diff<10**(-6)):
break
a1=a1/2
#print(a1)
print("no of iterations:",ite)
print("derivative is:",d)

def method2_derivative_at_x(a,b,c,d,x):
a1=0.1;prev_d=1;d=0;ite=0
while(True):
ite=ite+1
d=(f_x(a,b,c,d,x+a1)-f_x(a,b,c,d,x-a1))/(2*a1);
diff=d-prev_d
prev_d=d
if(diff<=10**(-6)):
break
a1=a1/2
print("no of iterations:",ite)
print("derivative is:",d)

derivative_at_x(1,1,1,1,1)
method2_derivative_at_x(1,1,1,1,1)
  

1 ##below is f(x) 2- def f_x(a,b,c,d,x): return a x**3+b*x**2+<*x+d; 5. def derivative_at_x(a,b,c,d,x): a1=0.1;prev_d=1;d=0;i
  

Add a comment
Know the answer?
Add Answer to:
python the polynomial equation is Ax^3+Bx^2+Cx+D b) Evaluating a polynomial derivative numerically For a function f(x),...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT