determining the number of divisions in riemann sums

2 ビュー (過去 30 日間)
WILLBES BANDA
WILLBES BANDA 2020 年 4 月 26 日
コメント済み: Aniket Devgun 2020 年 7 月 26 日
Hi, since riemann sum is all about adding smaller divided rectangles below the graph. I developed a code which calculates the difference between present sum and previous sum, when the difference is greater than 1e-5, the code must store the number of rectangles(terms) added to reach the difference and store the number of terms in n. c is the final area, the problem is that my code is not giving me the number of divisions nor the difference between sums, please help me find the (1).difference between sums and (2).the number of rectangles/divisions when the difference is greater than 1e-5
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)
if diff(c) > 0.00001
n = length(c)
end

採用された回答

David Hill
David Hill 2020 年 4 月 26 日
You did not say if you wanted left, right, middle riemann sum. This is left.
f = @(x)2*pi*(0.16*(0.25-(x-1).^2)+44.52).*(1+(-0.32*x - 0.32).^2).^1/2;
a=1;%whatever bounds you want
b=3;%whatever bounds you want
Rs(1) = f(a)*(b-a);
Rs(2) = sum(f(linspace(a,b,2)).*((b-a)/2));
n=2;
while abs(Rs(n)-Rs(n-1))>1e-5
n=n+1;
Rs(n) = sum(f(linspace(a,b,n)).*((b-a)/n));
end
  1 件のコメント
Aniket Devgun
Aniket Devgun 2020 年 7 月 26 日
What would it look like if it was a middle riemann sum?

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by