如何在R中的网格点上通过函数值给出的任意区域执行2D数值集成?

发布于 2025-01-24 22:52:16 字数 292 浏览 2 评论 0原文

我想数字评估形式的积分:

$$ int_d f(x,y)dx dy $$,

其中$ d $是$ r^2 $和$ f(x,y)$的区域从$ r^2 $到$ r $。

我有一个网格覆盖$ r^2 $的子集。从这个网格中,对于我的特定应用$ f(x,y)< 5 $)。

然后,我想在此选定的区域上集成该功能。在矩形区域上,2D积分存在许多功能,有些功能已实施以进行简单。在我看来,在更一般的区域上都没有集成。实施Riemann Sugs的版本似乎并不太复杂,但在任何地方都没有看到它。

有人知道吗?

I would like to numerically evaluate an integral of the form:

$$ int_D f(x,y) dx dy $$

where $D$ is a region in $R^2$ and $f(x,y)$ is a map from $R^2$ to $R$.

I have a grid covering a subset of $R^2$. From this grid, for my particular application, I select a particular region $D$ (not necessarily rectangular, but simply-connected) according to the value of $f(x,y)$ (for example, I select all points for which $f(x,y) < 5$).

I would then like to integrate the function over this selected region. Many functions exist for 2D integrals over rectangular regions and some have been implemented for integration over simplicies. It appears to me none exist for integration over more general regions. It does not seem too complicated to implement a version of Riemann Sums, but have not seen it anywhere.

Does anyone know?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北渚 2025-01-31 22:52:16

您可以为双变量使用Integral函数。

假设您有一个函数f(x,y)= xy/2,并且要将该函数与0&lt; x&lt; x&lt; 10 and 0&lt; y&lt; y&lt; x我们有:

integrate(Vectorize(function(x,y)integrate(function(y)0.5*x*y, 0, x)[[1]]), 0, 10)
625 with absolute error < 6.9e-12

这正是您手工获得的价值

You can use the integral function for bivariate.

Assume you have a function f(x, y) = xy/2 and you want to integrate the function with 0<x<10 and 0<y<x we have:

integrate(Vectorize(function(x,y)integrate(function(y)0.5*x*y, 0, x)[[1]]), 0, 10)
625 with absolute error < 6.9e-12

This is exactly the value you obtain by hand

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文