R******y 发帖数: 651 | 1 f[x_, y_, z_] := x^2 + y^2 + z^2;
g[x_, y_] := NIntegrate[f[x, y, z], {z, 0, 1}]
NIntegrate[g[x, y]^2 + g[x, y]^(1/2), {x, 0, 1}, {y, 0, 1}]
出错信息是
NIntegrate::inum: Integrand f[x, y, z] is not numerical at {z} = {0.5`}
我只要NIntegrate 的结果,Integrate 是没问题的。 | x***u 发帖数: 6421 | 2 你的g函数的定义不对。x和y都不知道没办法数值积分
这个破函数你干嘛要用数值积分,动动手就出来了 | R******y 发帖数: 651 | 3 你看一下function call 得顺序。
g 只是一个formula。
对f 积分,我想,mathematica 应该自己给mesh point. 在这些mesh point 上 g 是有
定义的。难道不是?
【在 x***u 的大作中提到】 : 你的g函数的定义不对。x和y都不知道没办法数值积分 : 这个破函数你干嘛要用数值积分,动动手就出来了
| x***u 发帖数: 6421 | 4 我的mathematica没你上面说的问题
【在 R******y 的大作中提到】 : 你看一下function call 得顺序。 : g 只是一个formula。 : 对f 积分,我想,mathematica 应该自己给mesh point. 在这些mesh point 上 g 是有 : 定义的。难道不是?
| R******y 发帖数: 651 | 5 你的是version 6?
没有出错信息,给出了正确结果?
【在 x***u 的大作中提到】 : 我的mathematica没你上面说的问题
| x***u 发帖数: 6421 | 6 In[1]:= f[x_, y_, z_] := x^2 + y^2 + z^2;
g[x_, y_] := NIntegrate[f[x, y, z], {z, 0, 1}];
NIntegrate[g[x, y]^2 + g[x, y]^0.5, {x, 0, 1}, {y, 0, 1}]
During evaluation of In[1]:= NIntegrate::inumr: The integrand \
x^2+y^2+z^2 has evaluated to non-numerical values for all sampling \
points in the region with boundaries {{0,1}}. >>
During evaluation of In[1]:= NIntegrate::inumr: The integrand \
x^2+y^2+z^2 has evaluated to non-numerical values for all sampling \
points in the region with boundaries
【在 R******y 的大作中提到】 : 你的是version 6? : 没有出错信息,给出了正确结果?
| l*0 发帖数: 195 | 7
~~~~~~~~~~ This should be Integrate
【在 R******y 的大作中提到】 : f[x_, y_, z_] := x^2 + y^2 + z^2; : g[x_, y_] := NIntegrate[f[x, y, z], {z, 0, 1}] : NIntegrate[g[x, y]^2 + g[x, y]^(1/2), {x, 0, 1}, {y, 0, 1}] : 出错信息是 : NIntegrate::inum: Integrand f[x, y, z] is not numerical at {z} = {0.5`} : 我只要NIntegrate 的结果,Integrate 是没问题的。
| S*********g 发帖数: 5298 | 8 No, that's not what he wanted.
Because in the real life problem, it could be impossible
for Mathematica to do an Integrate for the given f and g
The solution is:
NIntegrate[Hold[g[x,y]^2+Sqrt[g[x,y] ] ],{x,0,1},{y,0,1}]
【在 l*0 的大作中提到】 : : ~~~~~~~~~~ This should be Integrate
| x***u 发帖数: 6421 | 9 学习了,我原来以为是Evaluate,后来发现不是,原来是Hold函数。
【在 S*********g 的大作中提到】 : No, that's not what he wanted. : Because in the real life problem, it could be impossible : for Mathematica to do an Integrate for the given f and g : The solution is: : NIntegrate[Hold[g[x,y]^2+Sqrt[g[x,y] ] ],{x,0,1},{y,0,1}]
| dm 发帖数: 92 | 10 There seems to be a convention change since v6?
f[x_?NumberQ, y_?NumberQ, z_?NumberQ] := x^2 + y^2 + z^2;
g[x_?NumberQ, y_?NumberQ] := NIntegrate[f[x, y, z], {z, 0, 1}] |
|