First and Second Order Central Difference
显示 更早的评论
The 1st order central difference (OCD) algorithm approximates the first derivative according to
,
and the 2nd order OCD algorithm approximates the second derivative according to
.
In both of these formulae
is the distance between neighbouring x values on the discretized domain.
a.
Write a script which takes the values of the function
for
and make use of the 1st and 2nd order algorithms to numerically find the values of
and
. You may use the analytical value of
to find initial condtions if required.
for
and make use of the 1st and 2nd order algorithms to numerically find the values of b.
Plot your results on two graphs over the range
, comparing the analytical and numerical values for each of the derivatives.
, comparing the analytical and numerical values for each of the derivatives. c.
Compare each numerical algorithms results by finding the largest value of the relative error between the analytical and numerical results.
Can someone please help with this question? I'm stuck on where to begin really. Thanks! This is what I have so far, but comes up with errors.
clear all
f=@(x) cosh(x)
x=linspace(-4,4,9)
n=length(x)
i=1:n
h=x(i)-x(i-1)
xCentral=x(2:end-1);
dFCentral=(F(i+1)-F(i))/(h);
采纳的回答
更多回答(1 个)
Mk
2022-11-5
0 个投票
When Backward Difference Algorithm is applied on the following data points, the estimated value of Y at X=0.8 by degree one is_______ x=[0;0.250;0.500;0.750;1.000]; y=[0;6.24;7.75;4.85;0.0000];
a.
2.78
b.
3.78
c.
2.88
d.
3.88
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

