Help with basics and finite difference method

6 ビュー (過去 30 日間)
Will
Will 2014 年 9 月 14 日
コメント済み: Will 2014 年 9 月 15 日
I have to write a program using the finite-difference formula to calculate the approximate value for the derivative of a function. The test will be tan(x) for x=1, determining the error by comparing with sec^2(x). I have no idea where to begin.

採用された回答

Image Analyst
Image Analyst 2014 年 9 月 14 日
How about a for loop and taking the delta Y over the delta X where the separation is decreasing until it gets really really small, then compare to sec^2(x) and see how the difference gets smaller and smaller as the separation gets smaller and smaller. That's the finite difference method.
  7 件のコメント
Image Analyst
Image Analyst 2014 年 9 月 15 日
OK, great, glad I could help. Can you go ahead and mark the answer as Accepted then?
Will
Will 2014 年 9 月 15 日
I will, but I just talked to my instructor and he explained that though your method is valid, I must use the given formula. Could I just do the same things we talked about, only replace slope with
slope = (tan(x+h)-tan(x))/h
and do the error vs. h plot? I'm going to use loglog(h, error, -s), but this gives me a weird window... Please let me know if you can help with that as well, though I understand if you don't want to. Thanks for helping!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by