Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Write a Python function that evaluates the numerical derivative of an arbitrary function. Use the centered differences formula: dxdf(x)=2f(x+)f(x) where is a small number.

image text in transcribed

3. Write a Python function that evaluates the numerical derivative of an arbitrary function. Use the centered differences formula: dxdf(x)=2f(x+)f(x) where is a small number. Try to determine a good value for . You can provide this information as a comment in your code. The general structure should be: 1 def differentiate ( myfun, x): 2 \# your code goes here 3 4 \# derivative of sin(x) at x=1 5 \# derivative of x3 at x=2 Your program should generate the output: Numerical derivative of sin(x) at x=1 is 0.540302 Exact derivative of sin(x) at x=1 is 0.540302 Numerical derivative of x3 at x=2 is 12.000000 Exact derivative of x3 at x=2 is 12.000000 4. Write a Python function that numerically evaluates the second derivative of an arbitrary (mathematical) function. Use the same test problems as above. When you write the code, use the differentiate function developed above. Your program should generate the output: Numerical double derivative of sin(x) at x=1 is 0.841466 Exact double derivative of sin(x) at x=1 is 0.841471 Numerical double derivative of x3 at x=2 is 12.001511 Exact double derivative of x3 at x=2 is 12.000000 How does the choice of affect the accuracy of the

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

Students also viewed these Databases questions

Question

sharing of non-material benefits such as time and affection;

Answered: 1 week ago