matlab 不定积分 费米积分
想对y=x^0.5/(1+exp(x-s))进行积分0到无穷大,s是个常数,s=0时候可以得到答案,s=2就不行了,积分结果其实已知在1到3之间,只是想知道个准确数值,但...
想对y=x^0.5/(1+exp(x-s))进行积分0到无穷大,s是个常数,s=0时候可以得到答案,s=2就不行了,积分结果其实已知在1到3之间,只是想知道个准确数值,但系统提示Warning: Explicit integral could not be found.程序如下:
>> syms x;s=0;
y=x^0.5/(1+exp(x-s));
Fn=int(y,x,0,inf)
Fn =
1/2*pi^(1/2)*zeta(3/2)-1/4*pi^(1/2)*zeta(3/2)*2^(1/2)
>> 1/2*pi^(1/2)*zeta(3/2)-1/4*pi^(1/2)*zeta(3/2)*2^(1/2)
ans =
0.6781
>> syms x;s=2;
y=x^0.5/(1+exp(x-s));
Fn=int(y,x,0,inf)
Warning: Explicit integral could not be found.
> In E:\profile\matlab\toolbox\symbolic\@sym\int.m at line 58
Fn =
int(x^(1/2)/(1+exp(x-2)),x = 0 .. inf)
如果用quad怎么做?
>> s=0;
f=inline('y=x^0.5/(1+exp(x-s))','x');quad(f,0,10);
??? Error using ==> inlineeval
Error in inline expression ==> y=x^0.5/(1+exp(x-s))
??? Error: Assignment statements do not produce results. (Use == to test
for equality.)
Error in ==> E:\profile\matlab\toolbox\matlab\funfun\@inline\feval.m
On line 34 ==> INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in ==> E:\profile\matlab\toolbox\matlab\funfun\quad.m
On line 59 ==> y = feval(f, x, varargin{:});
我本来想用quad这样做,因为我还想计算当积分结果Fn为某值时,s=?可是不行。如果想求s要怎么做呢? 展开
>> syms x;s=0;
y=x^0.5/(1+exp(x-s));
Fn=int(y,x,0,inf)
Fn =
1/2*pi^(1/2)*zeta(3/2)-1/4*pi^(1/2)*zeta(3/2)*2^(1/2)
>> 1/2*pi^(1/2)*zeta(3/2)-1/4*pi^(1/2)*zeta(3/2)*2^(1/2)
ans =
0.6781
>> syms x;s=2;
y=x^0.5/(1+exp(x-s));
Fn=int(y,x,0,inf)
Warning: Explicit integral could not be found.
> In E:\profile\matlab\toolbox\symbolic\@sym\int.m at line 58
Fn =
int(x^(1/2)/(1+exp(x-2)),x = 0 .. inf)
如果用quad怎么做?
>> s=0;
f=inline('y=x^0.5/(1+exp(x-s))','x');quad(f,0,10);
??? Error using ==> inlineeval
Error in inline expression ==> y=x^0.5/(1+exp(x-s))
??? Error: Assignment statements do not produce results. (Use == to test
for equality.)
Error in ==> E:\profile\matlab\toolbox\matlab\funfun\@inline\feval.m
On line 34 ==> INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in ==> E:\profile\matlab\toolbox\matlab\funfun\quad.m
On line 59 ==> y = feval(f, x, varargin{:});
我本来想用quad这样做,因为我还想计算当积分结果Fn为某值时,s=?可是不行。如果想求s要怎么做呢? 展开
1个回答
展开全部
这样如何?
clc;clear;
myfun0=inline('x.^0.5./(1+exp(x-0))','x');
myfun1=inline('x.^0.5./(1+exp(x-1))','x');
myfun2=inline('x.^0.5./(1+exp(x-2))','x');
Q0 = quadl(myfun0,0,100)
Q1 = quadl(myfun1,0,100)
Q2 = quadl(myfun2,0,100)
结果:
Q0 =
0.6781
Q1 =
1.3964
Q2 =
2.5025
clc;clear;
myfun0=inline('x.^0.5./(1+exp(x-0))','x');
myfun1=inline('x.^0.5./(1+exp(x-1))','x');
myfun2=inline('x.^0.5./(1+exp(x-2))','x');
Q0 = quadl(myfun0,0,100)
Q1 = quadl(myfun1,0,100)
Q2 = quadl(myfun2,0,100)
结果:
Q0 =
0.6781
Q1 =
1.3964
Q2 =
2.5025
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询