Question

In: Advanced Math

Given x = [0, 0.05, 0.1, 0.15, 0.20, ... , 0.95, 1] and f(x) = [1,...

Given x = [0, 0.05, 0.1, 0.15, 0.20, ... , 0.95, 1] and f(x) = [1, 1.0053, 1.0212, 1.0475, 1.0841, 1.1308, 1.1873, 1.2532, 1.3282, 1.4117, 1.5033, 1.6023, 1.7083, 1.8205, 1.9382, 2.0607, 2.1873, 2.3172, 2.4495, 2.5835, 2.7183], write a Matlab script that computes the 1st and 2nd derivatives of O(h^2).

Solutions

Expert Solution

MATLAB Code:

close all
clear
clc

% O(h^2) first derivative:
% f'(x) = (f(x + h) - f(x - h)) / (2h)
%
% O(h^2) second derivative:
% f''(x) = (f(x + h) - 2*f(x) + f(x - h)) / (h^2)

% Given x and f(x)
x = 0:0.05:1;
f = [1, 1.0053, 1.0212, 1.0475, 1.0841, 1.1308, 1.1873, 1.2532, 1.3282, 1.4117, 1.5033, 1.6023, 1.7083, 1.8205, 1.9382, 2.0607, 2.1873, 2.3172, 2.4495, 2.5835, 2.7183];
h = 0.05; % Step in x
f_ = (f(3:end) - f(1:end-2)) / (2*h); % f'(x)
f__ = (f(3:end) - 2*f(2:end-1) + f(1:end-2)) / (h^2); % f''(x)

% Dumping the results in a table
fprintf('x\t\t\tf''(x)\t\tf''''(x)\n')
for i = 2:length(x)-1
fprintf('%.2f\t\t%.4f\t\t%.4f\n', x(i), f_(i-1), f__(i-1))
end

Output:


Related Solutions

Use the following data X                      f(X) 0 0.10 1 0.15 2 0.30 3 0.20 4 0.15...
Use the following data X                      f(X) 0 0.10 1 0.15 2 0.30 3 0.20 4 0.15 5 0.10 Graph the probability distribution of X Calculate ?" and ?$. Calculate the interval (?" ± 2?"). Superimpose this interval on the graph of the probability distribution of X. Also, calculate the interval (?" ± ?"). What proportion of the measurements will fall within these intervals? Does this result agree with Chebyshev’s Theorem? The Empirical Rule?
x P(x) 0 0.14 1 0.16 2 0.20 3 0.25 4 5 0.05 6 0.05
x P(x) 0 0.14 1 0.16 2 0.20 3 0.25 4 5 0.05 6 0.05
x P(x) 0 0.15 1 0.1 2 0.3 3 0.45 Find the mean of this probability...
x P(x) 0 0.15 1 0.1 2 0.3 3 0.45 Find the mean of this probability distribution. Round your answer to one decimal place. 2 x P(x) 0 0.05 1 0.15 2 0.25 3 0.55 Find the standard deviation of this probability distribution. Give your answer to at least 2 decimal places 3 2.36 Is it worth it?: Andy is always looking for ways to make money fast. Lately, he has been trying to make money by gambling. Here is...
Given f(x) = 1 x 2 − 1 , f 0 (x) = −2x (x 2...
Given f(x) = 1 x 2 − 1 , f 0 (x) = −2x (x 2 − 1)2 and f 00(x) = 2(3x 2 + 1) (x 2 − 1)3 . (a) [2 marks] Find the x-intercept and the y-intercept of f, if any. (b) [3 marks] Find the horizontal and vertical asymptotes for the graph of y = f(x). (c) [4 marks] Determine the intervals where f is increasing, decreasing, and find the point(s) of relative extrema, if any....
Find f. f ''(x) = x−2,    x > 0,    f(1) = 0,    f(4) = 0 f(x)=
Find f. f ''(x) = x−2,    x > 0,    f(1) = 0,    f(4) = 0 f(x)=
Given f(x,y) = 2 ; 0< x ≤ y < 1 a. Prove that f(x,y) is...
Given f(x,y) = 2 ; 0< x ≤ y < 1 a. Prove that f(x,y) is a joint pdf. b. Find the correlation coefficient of X and Y.
f(x)=0 if x≤0, f(x)=x^a if x>0 For what a is f continuous at x = 0...
f(x)=0 if x≤0, f(x)=x^a if x>0 For what a is f continuous at x = 0 For what a is f differentiable at x = 0 For what a is f twice differentiable at x = 0
Given: f(x,y) = 5 - 3x - y for 0 < x,y < 1 and x...
Given: f(x,y) = 5 - 3x - y for 0 < x,y < 1 and x + y < 1, 0 otherwise 1) find the covariance of x and y 2) find the marginal probability density function for x c) find the probability that x >= 0.6 given that y <= 0.2
Let f(x, y) be a function such that f(0, 0) = 1, f(0, 1) = 2,...
Let f(x, y) be a function such that f(0, 0) = 1, f(0, 1) = 2, f(1, 0) = 3, f(1, 1) = 5, f(2, 0) = 5, f(2, 1) = 10. Determine the Lagrange interpolation F(x, y) that interpolates the above data. Use Lagrangian bi-variate interpolation to solve this and also show the working steps.
The joint pmf of (X,Y) is depicted below. f(x,y) y=0 y-=1 y=2 y=3 x=0 0.02 0.05...
The joint pmf of (X,Y) is depicted below. f(x,y) y=0 y-=1 y=2 y=3 x=0 0.02 0.05 0.06 0.12 x=1 0.03 0.12 0.15 0.13 x=2 0.02 0.10 0.15 0.05 a.) What is the marginal pmf of X. b.) Calculate E(X). c.) What is the conditional pmf (probability mass function) of X given that Y = 1. d.) Calculate E(X | Y = 1). e.) Calculate Var(X | Y = 1). f.) What is the  cov(X,Y)? Note cov means covariance
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT