请教大神啊,数值积分的问题
mathematica吧
全部回复
仅看楼主
level 9
龙化要元 楼主
使用数值积分时候出现问题了,因为函数比较复杂,用Integrate耗时很长,用NIntegrate是不是时间短一点啊?但是问题来了,数值积分有时得不到结果,举个例子如下
Integrate[(5.25328 - x)^(0.23 - 1), x];
Integrate[(5.25328 - x)^(0.23 - 1), {x, 0, 5.25328}];
NIntegrate[(5.25328 - x)^(0.23 - 1), {x, 0, 5.25328}];
第一个能得到积分式子,第二个给出定积分数值,
第三个NIntegrate::zeroregion: Integration region {{5.25328,5.25328000000000017166712495949706583
13315518215
3581063474170620791}} cannot be further subdivided at the specified working precision. NIntegrate assumes zero integral there and on any further indivisible regions. >>NIntegrate::inumri: The integrand 1/(5.25328 -x)^0.77 has evaluated to Overflow, Indeterminate, or Infinity for all sampling points in the region with boundaries {{5.25328000000000017166712495949706583
13315518215
3581063474170620791,5.25328000000000017140366952968504617598149925854586194160721553198}}. >>
我的区间{0,5.25328},为什么它给弄个小区间{5.25328,5.2532800……1716……}且在这上面值超过范围了,怎么样才能让NIntegrate算出Integrate相同或者相近的结果而不是报错啊?谢谢啦。
2015年01月06日 09点01分 1
level 9
被积函数在那个点发散了,对精度要求不是很高的话直接去掉就可以了……
NIntegrate[(5.25328 - x)^(0.23 - 1), {x, 0, 5.25328}, Exclusions -> {x == 5.25328}] // Re
取实部是因为越界之后会出现虚的。不过说实话,这个函数特别简单,第一个绝对是最快的。因为发散没那么厉害,使用牛莱公式是合理的,所以:
Integrate[(5.25328 - x)^a, x] /. a -> (0.23 - 1) /. x -> {0, 5.25328} // Differences // First
用a是为了得到最简单的不定积分。
后面两个是准的。
2015年01月06日 11点01分 2
我照第一个运行不出来啊,我的9.0版本。
2015年01月06日 11点01分
level 9
龙化要元 楼主
@待人也轻以约
我照第一个运行不出来啊,我的9.0版本。
2015年01月06日 11点01分 3
Chop@NIntegrate[(5.25328 - x)^(0.23 - 1) // Rationalize, {x, 0, 5.25328 // Rationalize}] Rationalize是把小数转为精确数的函数
2015年01月06日 14点01分
吧务
level 11
Integrate[1/(32833/6250 - x)^(77/100), {x, 0, 32833/6250}] // N
NIntegrate[1/(32833/6250 - x)^(77/100), {x, 0, 32833/6250}]
NIntegrate[1/(32833/6250 - x)^(77/100), {x, 0, 32833/6250}, MaxRecursion -> 15, WorkingPrecision -> 20]
WolframAlpha["Integrate[(5.25328 - x)^(0.23 - 1), {x, 0, 5.25328}]", \
{{"Input", 1}, "Content"},
PodStates -> {"Input__Step-by-step solution", "Input__Hide steps"}]
6.36753是对的 但是数值积分在奇点需要增加采样密度或者增加最大递归深度与工作精度
2015年01月06日 14点01分 4
[真棒]
2015年01月07日 01点01分
1