forward, backward, center approximations for f(x) = e^x-2x+1

3 views (last 30 days)
how toget starded
  1 Comment
Walter Roberson
Walter Roberson on 10 Apr 2025
I suggest getting started by googling the formulas for forward, backwards, and center approximations.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 10 Apr 2025
Hint:
for K = 1 : numel(y);
xdiff(K) = x(K+2) - x(K+1);
end
for K = 1 : numel(y)
yleading(K) = y(K);
end
for K = 3 : numel(y)
ytrailing(K-2) = y(K);
end
for K = 1 : numel(yleading)
ydiff = ytrailing(K) - yleading(K);
end
for K = 1 : numel(ydiff)
centerdiff(K) = ydiff(K) ./ xdiff(K);
end
Note that there are deliberate bugs in this code... besides it being written in just about the most inefficient way possible.

Categories

Find more on Dates and Time in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!