Numerical Analysis: How does one write a MATLAB program to find the derivative of f(x)=xcosxf(x)=x^{\cos x} using the Richardson extrapolation table?
-
Can anyone write a MATLAB program to find the derivative of the following: f(x)=xcos(x) f(x)=x^{cos(x)} The inputs to the program are: x h The outputs are f'(x) = D(3,3), The estimated error = D(3,3) - D(3,2) Theoretically, I can solve it using the Richardson extrapolation table: Where: and:
-
Answer:
Instead of Richardson's, you can use the complex step derivative, which gives pretty accurate first order derivatives (depending on the chosen hh) The formula is: f'(x) \approx \frac{Im(f(x +ih))}{h} The code can be as simple as this: >>> f = @(x) x^(cos(x)); >>> h = eps; >>> x0 = 1.1; >>> df = imag(f(x0 + sqrt(-1)*h))/h See here for some background on complex step derivatives. http://en.wikipedia.org/wiki/Numerical_differentiation#Complex_variable_methods I should add that your particular function does not have real-valued derivatives everywhere.
Paul Artois at Quora Visit the source
Related Q & A:
- How do I write a good peer review?Best solution by Quora
- How do I write a search page?Best solution by Stack Overflow
- How can I write a good reference letter?Best solution by dailywritingtips.com
- How do I write a resume for a part-time job?Best solution by Yahoo! Answers
- How to write a TV program proposal?
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.