CS-550 ProgrammingHelp With ,Help With python Programming

BU MET CS-550: Comp. Math. for Data Analytics, v.1.0 Homework: Derivatives
Homework
Problem 1. Plot both the function f(·), its derivative f′(·), and the values of both at point x = 1 on the same plot for each of the following functions (take −3 ≤ x ≤ 3):
1. f(x) = 1 −→ f′(x) = 0
2. f(x) = x −→ f′(x) = 1
3.f(x)=x2 −→f′(x)=2x
4.f(x)=xn −→f′(x)=nxn−1, forn=3 5. f(x) = √x −→ f′(x) = 1/(2√x) 6.f(x)=ex −→f′(x)=ex
7. f(x) = 2x −→ f′(x) = (log a)ax
8. f(x) = logx −→ f′(x) = 1/x
9. f(x) = sinx −→ f′(x) = cos(x)
10. f(x) = cosx −→ f′(x) = −sin(x)
Color curves for f in green and curves for f′ in red, values for f(x = 1) and f′(x = 1) in black.
Page 0

BU MET CS-550: Comp. Math. for Data Analytics, v.1.0 Homework: Derivatives
Problem 2. derive the formulas for the first 4 functions in Problem 1.
Problem 3. read and install the ”sympy” Python package https://scipy-lectures.org/packages/sympy.html
Read the section on calculus (differentiation) and use the ”sympy” Python package to compute derivatives for each function in Problem 1.
Problem 4. for each of 10 functions in problem 1, write a script to compute f′(x = 1) using numerical differentiation with forward, backward and central differences for △x = 0.2. Summarize your results (rounded to 4 decimal digits) in the table as shown. For each row, color the closest value to exact in green and the furthest value in red. Discuss your findings.
Problem 5. for each of 10 functions in problem 1, write a script to compute the relative error (as percentage compared to the exact value) of computing derivatives f′(x = 1 using numerical differentiation with forward, backward and central differences for △x = 0.2. Summarize your results (rounded to 2 decimal digits) in the second table similar to the first one,
Page 1

BU MET CS-550: Comp. Math. for Data Analytics, v.1.0 Homework: Derivatives
Table 1: A Comparison of Derivatives
function
f(x)
1
x x2
···
···
cos(x)
forward
f(x+△x)−f(x) △x
backward
f(x)−f(x−△x) △x
central
f(x+△x)−f(x−△x) 2△x
exact f′(x = 1)