0

I would like to make a 3d plot of a function that takes as a variable a function of another variable.

The whole thing is complicated by the fact that my functions are nested piecewise functions

here is my code:

phi0=Function[u,1.21*10^-6/((u/10^44.25)^1.01 + (u/10^44.25)^2.38)][Lx]
zc=Function[v,Piecewise[{{2.49,v>=10^45.74},{2.49*(v/10^45.74)^0.2,v<10^45.74}}]][Lx]

e=Function[uu,Piecewise[{{(1+uu)^4.62,uu<=zc},{(1+zc)^4.62*((1+uu)/(1+zc))^-1.15,uu>zc}}]][z]

Plot3D[e[z,Lx],{z,0,7},{Lx,10^42,10^47}, PlotRange->Full]

but it is not plotting anything, and I am not sure of what to do

EDIT:

thanks, for the hint, I think I solved it this way. It is not giving me any error, but it is taking a lot of time to evaluate the result even in one single point... do you think it is normal?

phizero[Lx_] := 1.21/10^6/((Lx/10^44.25)^1.01 + (Lx/10^44.25)^2.38)

zc[Lx_] := 
 Piecewise[{{2.49, Lx >= 10^45.74}, {2.49*(Lx/10^45.74)^0.2, 
    Lx < 10^45.74}}]

e[z_, Lx_] := 
 Piecewise[{{(1 + z)^4.62, 
    z <= zc[Lx]}, {(1 + zc[Lx])^4.62*((1 + z)/(1 + zc[Lx]))^-1.15, 
    z > zc[Lx]}}]

phi[z_, Lx_] := phizero[Lx]*e[z, Lx]

(*D[phi[z,Lx],Lx]:=Lx*phi[z,Lx]*)

p[z_, Lx_] = Integrate[Lx*phi[z, Lx], Lx]
p[4, 10^44]
4

2 回答 2

1

首先,函数是这样工作的:

In[1]:= q = Function[x, x^2];
In[2]:= q[4]
Out[2]= 16

因此,请丢失每个函数定义末尾的 [var]。你也可以做

q[x_]:= x^2

如果这样更简单,则跳过使用 Function[] 。

接下来,您将函数 e 定义为接受一个参数,然后在 Plot3D 中使用它时给它两个参数。所以你需要弄清楚你对函数 e 的定义应该是什么,我什至无法猜测如何做到这一点。

于 2013-09-25T19:15:23.717 回答
0

这需要很长时间,因为它很难象征性地整合该功能。需要一段时间才能学会它不能完成。-- 使用 NIntegrate 进行数值积分。这是一个尝试。注意作为一个好习惯,我会在真正需要之前从表达式中省略浮点值:

 constants = {c1 -> 10^45.74, c2 -> 10^44.25, c3 -> 2.49, c4 -> 4.62, 
   c5 -> 2.38, c6 -> 0.2, c7 -> 1.21/10^6, c8 -> -1.15, c9 -> 1.01}
phizero[Lx_] := c7/((Lx/c2)^c9 + (Lx/c2)^c5)
zc[Lx_] := Piecewise[{{c3, Lx >= c1}, {c3 (Lx/c1)^c6, Lx < c1}}]
e[z_, Lx_] := 
      Piecewise[{{(1 + z)^c4, 
           z <= zc[Lx]}, {(1 + zc[Lx])^c4 ((1 + z)/(1 + zc[Lx]))^c8, 
           z > zc[Lx]}}]
phi[z_, Lx_] := phizero[Lx] e[z, Lx]
p[z_, L1_, L2_] := NIntegrate[Lx phi[z, Lx] /. constants, {Lx, L1, L2}]
p[4, 10^42, 10^47]

快速返回:

   (* ~7 10^84 *) 
于 2013-09-26T14:59:50.520 回答