Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your code cannot contain any import statements. It should also not contain print statements. The functions use the return statement to return the result of

Your code cannot contain any import statements. It should also not contain print statements. The functions use the return statement to return the result of the function call, so print statements should not occur in your solution.

image text in transcribedimage text in transcribed

Question #2 This question deals with the first derivative of a function f(r) on the real b) (BONUS) Produce a function derivative.comparison that has four numbers. Recall that arguments: . coefficients: a list of numbers representing the coefficients of a polynomial p() a: a number tol: a float with default value 0.01, h0 and so for small values of h, we can expect that f'(a) is close to lim-- if this limit exists. max.steps: a positive integer with default value 1000 Another way to express this is as follows: if the function f is differentiable at a then This function wil compare the exact value of p(a) computed using the function polynomial derivative from Question #1 (c) with the ap- proximate value of p'(a) obtained using the function derivative.quotient from part (a) of this question. since as n 00, (1) 0. So, for large enough values of n, this quotient should also be close to f'(a) derivative comparison(coefficients, a, tol, max steps) (a) Produce a function derivative.quotient that has three arguments will return the tuple (p'(a), q, n), where n is the smallest positive integer such that the difference between p(a) and the number q re- turned by derivative-quotient applied to p(r), a, and h = 1 is smaller than tol If the smallest such integer n is bigger than max.steps, the function should return the string 'Maximum number of steps exceeded.'. f, a, h where f is a function from float to float, a is a number, and h is a number, with default value 1e-4. derivative quotient(f, a, h) should return the number f(a h)- f(a) . You may assume that the given function f is defined at the num- For example, derivative.comparison([1, 2, 3], 10, 0.01, 10000) should return the tuple (62, 62.00996677739175, 301) since the deriva- tive of the polynomial p(x)-1 + 2x + 3r2 at a- 10 is 62, the value returned by derivative.quotient applied to p(x) with a-10 and h - 1/301 is equal to 62.00996677739175, and the difference between these two numbers is less than 0.01. On the other hand, derivative.comparison([1, 2, 3], 10, 0.0001) should return the string 'Maximum number of steps exceeded." bers a h and a For example, derivative-quotient (math.sin, 0, 0.1) should return the number 0.9983341664682815 since this is equal to (sin(0+0.1) sin(0))/(0.1). Note that in order to evaluate this particular expression you will need to import math in the console or in vou that you upload to the Avenue dropbox. r file. Do not include any import statements in the file . If h 0 your function should return the string "Division by 0 is not allowed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions