Integrating using sums(riemann sums)
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
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.
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
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.
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 ?
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.
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
