如何方便准确地计算一个区域的面积
考虑第一种情况,该区域能用解析表达式给出
测试用例:
RegionPlot[
x^2 + x^6/20 + y^2/2 + x y^2/15 < 2, {x, -2, 2}, {y, -2, 2}]
图如下:
一个简单易得的方法是蒙特卡洛法:
areaMC2D[region_, xintval_, yintval_, n_: 10000] :=
N[((Count[
Apply[region, ({RandomReal[xintval, n],
RandomReal[yintval, n]} // Transpose), {1}], True]/
n) (xintval[[2]] - xintval[[1]]) (yintval[[2]] -
yintval[[1]]))];
areaMC2D[Function[{x, y}, x^2 + x^6/20 + y^2/2 + x y^2/15 < 2], {-2,
2}, {-2, 2}, 1000]
但此法计算量偏大,且不很精确。
请问有没有其他方法或改进?
考虑第一种情况,该区域能用解析表达式给出
测试用例:
RegionPlot[
x^2 + x^6/20 + y^2/2 + x y^2/15 < 2, {x, -2, 2}, {y, -2, 2}]
图如下:
一个简单易得的方法是蒙特卡洛法:
areaMC2D[region_, xintval_, yintval_, n_: 10000] :=
N[((Count[
Apply[region, ({RandomReal[xintval, n],
RandomReal[yintval, n]} // Transpose), {1}], True]/
n) (xintval[[2]] - xintval[[1]]) (yintval[[2]] -
yintval[[1]]))];
areaMC2D[Function[{x, y}, x^2 + x^6/20 + y^2/2 + x y^2/15 < 2], {-2,
2}, {-2, 2}, 1000]
但此法计算量偏大,且不很精确。
请问有没有其他方法或改进?