由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Physics版 - mathematica 积分问题
相关主题
Numerical Integration in Mathematica理论物理PhD做什么好呢?
mathematica 2d对规则曲面的数值积分 怎么写?ask a mathematica plotting quesiton
一个积分问题帮忙解决一个数学问题(解方程)
请问有关mathematic的问题: (转载)问一个Mathematica的问题
问个弱问题问作理论的:老板会帮助你推导一些公式吗?
请问关于一个分部积分的问题 (转载)弱问一个Mathematica的问题
Re: a question about mathematica广义泛函积分怎么处理?
求助,这样的问题怎么处理请教关于三维相图
相关话题的讨论汇总
话题: nintegrate话题: integrate话题: numberq话题: integrand话题: numerical
进入Physics版参与讨论
1 (共1页)
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}]
1 (共1页)
进入Physics版参与讨论
相关主题
请教关于三维相图问个弱问题
mathematica 可以这样输出文件马请问关于一个分部积分的问题 (转载)
复数问题弱问Re: a question about mathematica
解方程 x=sin(x)求助,这样的问题怎么处理
Numerical Integration in Mathematica理论物理PhD做什么好呢?
mathematica 2d对规则曲面的数值积分 怎么写?ask a mathematica plotting quesiton
一个积分问题帮忙解决一个数学问题(解方程)
请问有关mathematic的问题: (转载)问一个Mathematica的问题
相关话题的讨论汇总
话题: nintegrate话题: integrate话题: numberq话题: integrand话题: numerical