Integrating using sums(riemann sums)
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi, i want to find the integral of function f without using the int function with the limits 5 and 17 . I want to find the riemann sum of the function f.
I tried solving it by using the int function but now i want to find the area withou using int. below is my code but n should represent the number of divisions that gives an accuracy of 10^-4 , i am not sure if my value of n is correct or not? how do i find n and the area (c) ?please help.
format longG
syms x
f = 2*pi*(0.16*(0.25-(x-1)^2)+44.52)*(1+(-0.32*x - 0.32)^2)^1/2;
a = int(f,5,17.688);
b = sym(a);
c = double(b);
n = (17.688-5)/0.0001;
SurfaceArea = [c n]
採用された回答
Birdman
2020 年 4 月 1 日
You may use rsums. It allows you to interactively calculate the riemann sum integral:
rsums(f,5,17.688)
10 件のコメント
WILLBES BANDA
2020 年 4 月 1 日
Thank you for your answer
but this works exactly the same as int function, cant we form a loop that calculates the area of each rectangle under the graph and then sum up to give us the overall area without using functions like int or rsums? Please help.
Birdman
2020 年 4 月 1 日
f=@(x) 2*pi*(0.16*(0.25-(x-1)^2)+44.52)*(1+(-0.32*x - 0.32)^2)^1/2;
dt=0.0001;
N=5:dt:17.688;
riemannSumIntegral=0;
for i=1:numel(N)
riemannSumIntegral=riemannSumIntegral+f(N(i))*dt;
end
WILLBES BANDA
2020 年 4 月 1 日
it works perfectly fine, at least i will have to find the number of divisions(n) required for the area to have an accuracy of 10^-4 . Thank you honourable
Steven Lord
2020 年 4 月 1 日
Is that possible to do? Sure.
If you're asking us to write it and post, I'm hesitant to do so as that feels like a fairly common homework assignment in a numerical analysis course.
If you've written such a function and need help diagnosing and fixing a problem with it, post your function, the problem you're trying to solve, and an explanation of the problem you're experiencing and we may be able to offer some guidance.
WILLBES BANDA
2020 年 4 月 1 日
From the code that i wrote above as part of the question, the number of divisions is represented by n. And i took the difference between the interval and divided it by 0.0001 but i still get a wrong answer. So i also need help diagnosing and fixing the problem with finding the number of divisions, apologies for not being more clear when posting the question.
Torsten
2020 年 4 月 1 日
You got an answer from your own code ? Where is this code ?
WILLBES BANDA
2020 年 4 月 1 日
this was my initial code that was part of the question and i am trying to figure out the number of divisions required to get an accuracy of 10^-4
format longG
syms x
f = 2*pi*(0.16*(0.25-(x-1)^2)+44.52)*(1+(-0.32*x - 0.32)^2)^1/2;
a = int(f,5,17.688);
b = sym(a);
c = double(b);
n = (17.688-5)/0.0001;
SurfaceArea = [c n]
Torsten
2020 年 4 月 1 日
Take the result from int as the correct value for the integral.
Then test which values you get for the integral for h=1e-2,1e-3,1e-4,... using Riemann sums and compare with the value you got from int. As soon as the difference between the values is smaller than1e-4, you got the adequate step size. Note that it's usually not possible to determine the h in advance,only by testing.
WILLBES BANDA
2020 年 4 月 1 日
Noted. Thank you Honourable
Elvin
2023 年 7 月 20 日
I tried this but it says "unrecognized function"
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
製品
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
