我正在尝试计算八度上的二重积分

发布于 2025-01-16 04:12:19 字数 401 浏览 2 评论 0原文

所以我需要评估八度音程上的二重积分[![question][1]][1]

>> x1 = 1;
>> x2 = 0;
>> y1 = 2;
>> y2 = 0;
>> f = @(x,y) (y-x)./((x+y).^3);
>> integral2(f,x2,x1,y2,y1);

我输入了上面的代码,但它给了我错误:“达到子图块的最大数量,精度可能很低”并给出 NAN作为答案。有什么解决办法吗? 这是我需要评估的积分: https://i.sstatic.net/Xv5AM.png

So I have need to evaluate double integral on octave[![question][1]][1]

>> x1 = 1;
>> x2 = 0;
>> y1 = 2;
>> y2 = 0;
>> f = @(x,y) (y-x)./((x+y).^3);
>> integral2(f,x2,x1,y2,y1);

I entered the above code but it gives me error: "Maximum number of sub-tiles reached, accuracy may be low" and gives NAN as answer. Any solutions?
This is the integral I need to evaluate: https://i.sstatic.net/Xv5AM.png

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

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

发布评论

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

评论(2

时光礼记 2025-01-23 04:12:19

您可以为被积函数定义一个函数 f

f = @(x,y) (yx)./(x+y).^3

请注意逐元素./.^ 函数以避免矩阵运算。现在使用 dblquad 函数:

dblquad(f,0,2,0,1)

其中最后四个输入参数是 x 的积​​分限制> 和y。您还可以使用其他输入参数指定不同的容差和积分器函数,但在这种情况下默认值可以正常工作。我用这个方法得到了你所期待的答案。

对于单行运算,您可以使用

dblquad( @(x,y) (yx)./(x+y).^3 , 0 , 2 , 0 , 1 )< 来跳过创建被积函数/代码>

You can define a function f for your integrand:

f = @(x,y) (y-x)./(x+y).^3

Note the element-wise ./ and .^ functions to avoid matrix operations. Now use the dblquad function:

dblquad(f,0,2,0,1)

where those last four input arguments are your integration limits for x and y. You can also specify a different tolerance and an integrator function with additional input arguments, but the defaults work fine in this case. I obtained the answer you were expecting with this method.

For a single-line operation, you can skip creating the integrand function by using

dblquad( @(x,y) (y-x)./(x+y).^3 , 0 , 2 , 0 , 1 )

情深如许 2025-01-23 04:12:19

这可能是因为在 0,0 处计算的函数返回 NaN。

这就提出了一个问题,您希望如何处理 0,0?

该限制似乎为零,因此您可以尝试将其排除到数值精度。

以下:

a = integral2(f,x2+eps,x1,y2+eps,y1, 'method', 'iterated');

对我有用,但这个结果的解释取决于你......

This is probably because the function evaluated at 0,0 returns NaN.

Which raises the question, how would you like 0,0 to be treated?

The limit seems to be zero, so you could try excluding it up to numerical precision.

The following:

a = integral2(f,x2+eps,x1,y2+eps,y1, 'method', 'iterated');

worked for me, but interpretation of this result is up to you ...

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