如何在MATLAB中确定积分的上限来求解数值?

发布于 2025-02-03 23:53:58 字数 1093 浏览 1 评论 0原文

给定等式

“

对于某些给定函数f(x)其中gamma也给出了,如何才能数字上可以在matlab中求解上限u

f(x)可以是任何模型的占位符。

这是一个从根角和集成问题的问题,但是由于我在MATLAB缺乏知识,我仍在努力弄清楚它是如何完成的。

我的最初解决方案是一种蛮力的方法。假设我们有

“在此处输入图像描述”

gamma = 0.8,我们可以从-infu by找到确定的积分从一些非常小的值u中提取其积分,直到我们达到结果gamma = 0.8

syms f(x)
f(x) = (1/(sqrt(6*pi)))*exp(-(x^2/6));  
gamma = 0.8;
u = -10;

res = int(f,x,-Inf,u);
while double(res) <= gamma
    u = u+0.1;
    res = int(f,x,-Inf,u);
end
fprintf("u is %f", u);

该解决方案非常慢,绝对不会一直工作。

我设置u = 10,因为查看函数的图,我们实际上没有在间隔之外得到任何东西[-5,5]。

Given the equation

f(x) = int_{-infty}^

For some given function f(x) where gamma is also given, how can you numerically solve for upper bound u in Matlab?

f(x) can be a placeholder for any model.

This is a root-finding and integration problem but with my lack of knowledge in Matlab, I'm still trying to figure out how it is done.

My initial solution is a brute force approach. Let's say we have

enter image description here

and gamma = 0.8, we can find the definite integral from -inf to u by extracting its integral from some very small value u, working our way up until we reach a result gamma = 0.8.

syms f(x)
f(x) = (1/(sqrt(6*pi)))*exp(-(x^2/6));  
gamma = 0.8;
u = -10;

res = int(f,x,-Inf,u);
while double(res) <= gamma
    u = u+0.1;
    res = int(f,x,-Inf,u);
end
fprintf("u is %f", u);

This solution is pretty slow and will definitely not work all the time.

I set u = 10 because looking at the graph of the function, we don't really get anything outside the interval [-5, 5].

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

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

发布评论

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

评论(1

删除→记忆 2025-02-10 23:53:58

您可以使用MATLAB符号数学工具箱(可能需要安装的附加组件)。
这样,您可以将自己定义一个“ true”不知道的变量x(不是x值数组),然后从负面的无穷大集成:

syms f(x)
f(x) = exp(2*x)  % an example function
gamma = int(f,x,-Inf,u)

这使gamma作为来自>> inf u,在定义f(x)为符号函数之后,将u作为标量

You can use MATLAB Symbolic Math Toolbox (an addon you might need to install).
That way you can define yourself a "true" unknow variable x (not an array of x-values) and later integrate from negative infinity:

syms f(x)
f(x) = exp(2*x)  % an example function
gamma = int(f,x,-Inf,u)

This yields gamma as the integral from -Inf to u, after defining f(x) as a symbolic function and u as a scalar

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