The area of the first quadrant in the equation of a circle
can be calculated using the integral likes below.
We use integral for get the area of under the graph.
But, computer can compute this as the sum of area of thin bars.
(because computers have fast computational processing power)
It can be obtained as shown in the figure below.
There must be exist an error this way.
But if we calculate δ as very small value, its result be more accurate.
Below code is intergration using rectangle bars which explained above.
when I put delta = 0.0001 and r = 2 in this code,
result = 3.1416922378
real Pi = 3.1415926536
result > real Pi and Error rate = 0.0031698635368 %
If using trapezoid bars, it will be more accurate like below figure.
when I put delta = 0.0001 and r = 2 in this code,
result = 3.1415922379
real Pi = 3.1415926536
result < real Pi and Error rate = 0.000013232141969 %
Using trapezoid bars is more accurate than using rectangle bars.
'Research & Algorithm > 수치해석' 카테고리의 다른 글
[수치해석] Gauss Elimination을 이용한 연립 방정식 해 계산 (Python) (0) | 2023.03.20 |
---|---|
[수치해석] Python을 이용한 수치 미분과 Taylor series expansion을 이용한 오차 분석 (1) | 2023.01.08 |
[수치해석] Python을 이용한 Machine epsilon(한계 오차) 계산 (0) | 2023.01.06 |
[C++] Get area using Monte Carlo method (0) | 2022.10.01 |