Numerical Methods Backward Difference
14 views (last 30 days)
Show older comments
Hi guys. I was trying to differentiate that problem. I can solve it by hand but I'm really bad on matlab. I didn't see like this type of example on matlab. I don't have any guide for this type of questions. Problem is this:
Assuming y (x) is a smooth function defined on the interval [0; 1] ; obtain a second order of
accuracy approximation formula for y''' (1) (third order derivatives).
I know we have to use backward formula. We have 2+3= 5 unknows.
Backward formula is this: v(t) = ((fx(t)) - (fx(t)-h))/h;
The question is 'You can make use of MATLAB software to find
the unknown coefficients'.
Thank you for your answers.
2 Comments
Dana
on 1 Sep 2020
I don't understand the question. What does it mean to have a "second order of accuracy approximation formula for y'''(1)"? I understand what it means to find, say, a second-order Taylor approximation around x=1, but in that case you want
What does this have to do with y'''(1)?
Also, do you have a particular functional form for y(x)? Or is it an arbitrary function? And what is fx(t)?
Spending a little more time trying to make your question clear and precise will improve your chances of getting a helpful reply.
Answers (1)
John D'Errico
on 1 Sep 2020
Edited: John D'Errico
on 1 Sep 2020
I won't directly do your homework for you. I'll show you how you might solve for the coefficients of a formula you should already know though. And there is probably a simpler way to do it.
syms x h y0 yp ypp yppp ypppp
syms a0 a1
yhat = y0 + yp*x + ypp*x^2/2 + yppp*x^3/2 + ypppp*x^4/24
yhat =
(ypppp*x^4)/24 + (yppp*x^3)/2 + (ypp*x^2)/2 + yp*x + y0
Now, can I solve for a simple backwards finite difference formula for the first derivative of y, at x == 0?
Consider the general backwards finite difference, with unknown coefficients a0 and a1.
findiff = expand(a0*subs(yhat,x,0) + a1*subs(yhat,x,-h))
findiff =
(a1*ypppp*h^4)/24 - (a1*yppp*h^3)/2 + (a1*ypp*h^2)/2 - a1*yp*h + a0*y0 + a1*y0
Now, the simple way to extract the coefficient of some derivative is to just differentiate with respect to that parameter.
A = solve(diff(findiff,y0) == 0,diff(findiff,yp) == 1,a0,a1)
A =
struct with fields:
a0: [1×1 sym]
a1: [1×1 sym]
subs(findiff,[a0,a1],[A.a0,A.a1])
ans =
- (ypppp*h^3)/24 + (yppp*h^2)/2 - (ypp*h)/2 + yp
A.a0
ans =
1/h
A.a1
ans =
-1/h
As you can see, this is the simple backwards finite difference formula to estimate the first dervative of y at x==0. How about the error term? That is the lowest order term in h.
Can you do the same thing for a finite difference approximation to yield the third derivative? I hope so, since I pretty much did your homework here, at least if you think about it.
And, again, I am sure I could have done this more directly.
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!