Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Be sure to include appropriate comments in your code, and to use descriptive input and output statements. IN PYTHON CODE Palayi apie 3LYICS Activity #2:
Be sure to include appropriate comments in your code, and to use descriptive input and output statements.
IN PYTHON CODE
Palayi apie 3LYICS Activity #2: Taking limits to compute derivatives - To be done as a team In an earlier lab, we observed how we could have a function that is undefined at some value (such as (sin x)/x at the point x=0), but could come arbitrarily close to it by successively evaluating smaller and smaller numbers (i.e. taking a limit). For example, we might evaluate at x=0.1, x=0.01, x=0.001, etc. until we have come very close to the value. Taking limits like this, numerically, is commonly done when functions are too complicated to evaluate analytically. You will write a program to compute a derivative as a numerical limit. This activity has a three parts. Please name the files as stated above under the Deliverables section. You may reuse code from activity #1 if it is helpful. a) Evaluating a polynomial limit analytically You should have learned by now the process for finding the derivative of a polynomial (as another polynomial). Write a program that will read in from the user a cubic polynomial f(x) (as a set of 4 coefficients), and use this to compute the derivative polynomial (i.e. compute the three coefficients of the derivative f'(x)). Then, read in a value for x from a user, and evaluate the derivative polynomial at that x. Print out that value with appropriate labels. b) Evaluating a polynomial derivative numerically For a function f(x), the derivative of the function at a value x can be found by evaluating and finding the limit as a gets closer and closer to 0. Using the same polynomial as the user entered in part (a), and for the same value of x as entered in part (a), compute the limit f(x+a)-f(x) .cina value for a such as numerically. That is, start with an estimate by evaluating 0.1. Then, repeatedly halve the value of a until the difference between successive evaluations of TATT() is less than some small value, such as 10-6. Print the result, along with the number of evaluations it took. Calculate how close that result is to the actual answer, computed in part (a). a - f(x)-f(x-a) Repeat the above activity by evaluating the limits of the following expressions:- TATT(4) Tru computing each of those, and calculate how many iterations you need to 2a converge to the limit. Do you get different results with any of them, or does any of them take fewer steps to get an answer? (Put your answer as a comment in your code.) c) Evaluating a more complex function. Specify three functions to play with. In your own code, come up with four more complex functions (not a polynomial - e.g. use sin/cos/tan/exp/log/powers/etc.), that you do not know how to compute the derivative for analytically, but that you can evaluate. For each function, using the same process as in part (b), calculate the derivative of that function at some value. Write a line of output describing each function, and stating what the computed derivative for it is, along with the number of steps needed to compute the derivative. Palayi apie 3LYICS Activity #2: Taking limits to compute derivatives - To be done as a team In an earlier lab, we observed how we could have a function that is undefined at some value (such as (sin x)/x at the point x=0), but could come arbitrarily close to it by successively evaluating smaller and smaller numbers (i.e. taking a limit). For example, we might evaluate at x=0.1, x=0.01, x=0.001, etc. until we have come very close to the value. Taking limits like this, numerically, is commonly done when functions are too complicated to evaluate analytically. You will write a program to compute a derivative as a numerical limit. This activity has a three parts. Please name the files as stated above under the Deliverables section. You may reuse code from activity #1 if it is helpful. a) Evaluating a polynomial limit analytically You should have learned by now the process for finding the derivative of a polynomial (as another polynomial). Write a program that will read in from the user a cubic polynomial f(x) (as a set of 4 coefficients), and use this to compute the derivative polynomial (i.e. compute the three coefficients of the derivative f'(x)). Then, read in a value for x from a user, and evaluate the derivative polynomial at that x. Print out that value with appropriate labels. b) Evaluating a polynomial derivative numerically For a function f(x), the derivative of the function at a value x can be found by evaluating and finding the limit as a gets closer and closer to 0. Using the same polynomial as the user entered in part (a), and for the same value of x as entered in part (a), compute the limit f(x+a)-f(x) .cina value for a such as numerically. That is, start with an estimate by evaluating 0.1. Then, repeatedly halve the value of a until the difference between successive evaluations of TATT() is less than some small value, such as 10-6. Print the result, along with the number of evaluations it took. Calculate how close that result is to the actual answer, computed in part (a). a - f(x)-f(x-a) Repeat the above activity by evaluating the limits of the following expressions:- TATT(4) Tru computing each of those, and calculate how many iterations you need to 2a converge to the limit. Do you get different results with any of them, or does any of them take fewer steps to get an answer? (Put your answer as a comment in your code.) c) Evaluating a more complex function. Specify three functions to play with. In your own code, come up with four more complex functions (not a polynomial - e.g. use sin/cos/tan/exp/log/powers/etc.), that you do not know how to compute the derivative for analytically, but that you can evaluate. For each function, using the same process as in part (b), calculate the derivative of that function at some value. Write a line of output describing each function, and stating what the computed derivative for it is, along with the number of steps needed to compute the derivativeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started