3. (50 points) You are given a function f(x) = sin(x) + cos(x) on the interval...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
3. (50 points) You are given a function f(x) = sin(x) + cos(x) on the interval [-3,1] and you want to calculate the first derivative of this function at the points on this interval. Write a MATLAB program that: (a) Given the number N of subintervals, calculates the first derivative of the function, fi, at each point x, including the boundary points, with the first-order accuracy (this can be done as a self-written MATLAB function). You can use any formula of O(h) of your choice. (b) Given the number N of subintervals, calculates the first derivative of the function, f, at each point x, including the boundary points, with the second-order accuracy (this can be done as a self-written MATLAB function). You can use any formula of O(h) of your choice. (c) Calculates two measures of error defined as i. EL = maxi|ftrue (xi) fi| - ii. EL2 = N (firue(xi)-f) i=0 N+1 The first error is called the error in infinity norm (max; stands for the maximum value among all the points), and the second error is called the error in L2 norm. Here ftrue (xi) is the true value of derivative at the given point xi. You need: (a) Provide a write-up stating all the formulas you used for calculating the derivative for the first- order method, and for the-second order method, for the interior points, as well as for the left and right boundary points. (b) Run your program with the number of intervals N equal to 8, 16, 32, 64. (c) For N = 8 and N = 64, output the derivatives at the left and right boundary points. (d) Plot EL versus N, in log-log plot, for both the first-order method, and the second-order method, on the same plot. (e) Plot EL2 versus N, in log-log plot, for both first-order method, and the second-order method, on the same plot (but different from EL plot). (f) Estimate the order of accuracy for each derivative from the two plots (either calculate the slope from the graphs, or plot the theoretical order of convergence lines). (g) Discuss if you obtain the expected order of convergence, for both error measures. 3. (50 points) You are given a function f(x) = sin(x) + cos(x) on the interval [-3,1] and you want to calculate the first derivative of this function at the points on this interval. Write a MATLAB program that: (a) Given the number N of subintervals, calculates the first derivative of the function, fi, at each point x, including the boundary points, with the first-order accuracy (this can be done as a self-written MATLAB function). You can use any formula of O(h) of your choice. (b) Given the number N of subintervals, calculates the first derivative of the function, f, at each point x, including the boundary points, with the second-order accuracy (this can be done as a self-written MATLAB function). You can use any formula of O(h) of your choice. (c) Calculates two measures of error defined as i. EL = maxi|ftrue (xi) fi| - ii. EL2 = N (firue(xi)-f) i=0 N+1 The first error is called the error in infinity norm (max; stands for the maximum value among all the points), and the second error is called the error in L2 norm. Here ftrue (xi) is the true value of derivative at the given point xi. You need: (a) Provide a write-up stating all the formulas you used for calculating the derivative for the first- order method, and for the-second order method, for the interior points, as well as for the left and right boundary points. (b) Run your program with the number of intervals N equal to 8, 16, 32, 64. (c) For N = 8 and N = 64, output the derivatives at the left and right boundary points. (d) Plot EL versus N, in log-log plot, for both the first-order method, and the second-order method, on the same plot. (e) Plot EL2 versus N, in log-log plot, for both first-order method, and the second-order method, on the same plot (but different from EL plot). (f) Estimate the order of accuracy for each derivative from the two plots (either calculate the slope from the graphs, or plot the theoretical order of convergence lines). (g) Discuss if you obtain the expected order of convergence, for both error measures.
Expert Answer:
Related Book For
An Introduction to the Mathematics of financial Derivatives
ISBN: 978-0123846822
2nd Edition
Authors: Salih N. Neftci
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Find the volumes of the solids generated by revolving the regions bounded by the lines and curves about the x-axis. The region between the curve and the x-axis from x = 1/4 to x = 4 y = 1/(2x)
-
Consider the mixture described in the previous problem, but suppose it is heated to 3900oC and compressed to 15.0 atm. Kp at this temperature is 0.0123. What is the equilibrium composition of the...
-
Coca-Cola recently introduced Coca-Cola Orange No Sugar as a limited edition flavor. Why would Coca-Cola market this product using the Coca-Cola brand name instead of creating a new brand? What are...
-
Cooling pipes at three nuclear power plants are investigated for deposits that would inhibit the flow of water. From 30 randomly selected spots at each plant, 13 from the first plant, 8 from the...
-
Gepetto Shoe Store uses the retail inventory method for its two departments, Womens Shoes and Mens Shoes. The following information for each department is obtained. Instructions Compute the estimated...
-
You are the HR Manager of a rapidly expanding technology company that acquired a smaller tech firm 2 years ago. Both companies had maintained low turnover rates in their respective call centers prior...
-
1- Airlines and hotels (local and global) are planning their programmes and offerings for the spring season and want to generate sales. They started to communicate with their customers/guests about...
-
A die is rolled 8 times. What is the probability that we will get exactly two 3s?
-
If negative goodwill is still remaining after allocations, the remaining amount is recognized as an extraordinary gain. Does this meet the definition of an extraordinary item?
-
What are the three requirements to be eligible for differential reporting?
-
In Problems 11-18, find the three measures of central tendency (the mean, median, and mode). 1, 2, 3, 4, 5
-
If externally reported financial statements are general purpose statements, how can specific objectives influence their content?
-
Sales for your 120-store womens clothing chain are down 42% for the last fiscal year compared to the previous year. Management is upset and wants to know what caused the serious decline. You must...
-
a. What is the cost of borrowing if Amarjit borrows $28 500 and repays it over a four-year period? b. How many shares of each stock would he get if he used the $28 500 and invested equally in all...
-
When a honeybee flies through the air, it develops a charge of +17 pC. How many electrons did it lose in the process of acquiring this charge?
-
Falling raindrops frequently develop electric charges. Does this create noticeable forces between the droplets? Suppose two 1.8 mg drops each have a charge of +25 pC; these are typical values. The...
-
A housefly walking across a surface may develop a significant electric charge through a process similar to frictional charging. Suppose a fly picks up a charge of +52 pC. How many electrons does it...
Study smarter with the SolutionInn App