Double integral of a function (Beginners Question)
Subject: Double integral of a function (Beginners Question)
From: Doktor Bernd
Date: Mon, 7 Jun 2010 13:03:46 +0000
Thank you for your help!
If I got it right, I could remove the block stuff, but it should not nurt having them
So I leave it as it is for now.
For the second Problem, I am back where I started.
When I remove all qotes, I get:
(%i20) Lambda : 0 $
Theta : 1 $
Theta_inv : 1-Theta $
W_0 : 0.0254 $
L : 50000 $
Cn2 : 1e-17 $
li : 0.005 $
lo : 5.0 $
k : 7.139983303613165e+006 $
r : 0 $
Cn2(l) := block([l:l], 1e-17) $
rho_0(k,L,Cn2) := block([k:k,L:L,Cn2:Cn2],(1.46*k^2*integrate(Cn2(l),l,0,L))^(-3/5)) $
ka2x(k,l,Cn2) := block([k:k,l:l,Cn2:Cn2],(0.38/k + 0.35*(l/(k*rho_0(k,l,Cn2)))^2)^-1) $
ka2y(k,l,Cn2) := block([k:k,l:l,Cn2:Cn2],3*k/l + 1.7/rho_0(k,l,Cn2)) $
f(kappa,li):= block([kappa:kappa,li:li],exp(-kappa^2/(3.3/li)^2)*(1+1.803*(kappa/(3.3/li))-0.254*(kappa/(3.3/li))^(7/6))) $
g(kappa,lo):= block([kappa:kappa,lo:lo],(1-exp(-kappa^2/(8*%pi/lo)^2))) $
spec(Cn2,kappa,ka2x,ka2y,li,lo):= block([Cn2:Cn2,kappa:kappa,ka2x:ka2x,ka2y:ka2y,li:li,lo:lo],0.033*Cn2*kappa^(-11/3)* f(kappa,li) * g(kappa,lo) *exp(-(kappa^2)/(ka2x))+(kappa^(11/3))/(kappa^2+ka2y^2)^(11/6)) $
integrand(kappa,Cn2,l,L,Lambda,Theta_inv,xi,k,r):= block([kappa:kappa,Cn2:Cn2,l:l,L:L,Lambda:Lambda,Theta_inv:Theta_inv,xi:xi,k:k,r:r],kappa*spec(Cn2,kappa,ka2x(k,l,Cn2),ka2y(k,l,Cn2),li,lo)*exp(-(Lambda*L*kappa^2*xi^2)/(k)) * (bessel_i(0,2*Lambda*r*kappa*xi)-cos((L*kappa^2)/k)*xi*(1-Theta_inv*xi))) $
float(integrate((integrate((integrand(kappa,Cn2,(1-xi)/L,L,Lambda,Theta_inv,xi,k,r)),kappa,0,inf)),xi,0,1));
defint: variable of integration must be a simple or subscripted variable.
defint: found (1-xi)/50000
#0: rho_0(k=7139983.303613165,l=(1-xi)/50000,cn2=1.0000000000000001E-17)
#1: ka2x(k=7139983.303613165,l=(1-xi)/50000,cn2=1.0000000000000001E-17)
#2: integrand(kappa=kappa,cn2=1.0000000000000001E-17,l=(1-xi)/50000,l=50000,lambda=0,theta_inv=0,xi=xi,k=7139983.303613165,r=0)
-- an error. To debug this try: debugmode(true);
I thought this error is due to the evaluation of the parameters as they are passed to the functions. So the quotes should deferre the evaluation of the expressions until the last statement.
What is the correct way to evaluate the double integral?
All the best,
Bernd
> From: rswarbrick at gmail.com
> To: doktorbernd at hotmail.com
> CC: maxima at math.utexas.edu
> Subject: Re: Double integral of a function (Beginners Question)
> Date: Mon, 7 Jun 2010 12:27:46 +0100
>
> Doktor Bernd <doktorbernd at hotmail.com> writes:
> <snip>
> > rho_0(k,L,Cn2) := block([k:k,L:L,Cn2:Cn2],(1.46*k^2*integrate(Cn2(l),l,0,L))^(-3/5)) $
> <snip more>
> > My questions are:
> >
> > Do I have to use the blocks?
> > I read at some places that I have to and at others that all passed variables are treated as local ones.
> >
> > Why do I not get a result from the last statement?
> > I guess I am using ' in a wrong way.
>
> Well, I'll answer the easy one at least :-) What block does is set up
> local bindings for a variable. So
>
> foo(x) := block([a], a: x);
>
> doesn't do anything (it sets up a local binding for a, sets a to x and
> then forgets about a again). On the other hand,
>
> bar(x) := a: x;
>
> affects the bindings for a
>
> Transcript:
>
> (%i1) foo(x) := block([a], a: x);
> (%o1) foo(x) := block([a], a : x)
> (%i2) foo(3);
> (%o2) 3
> (%i3) a;
> (%o3) a
> (%i4) bar(x) := a: x;
> (%o4) bar(x) := a : x
> (%i5) bar(3);
> (%o5) 3
> (%i6) a;
> (%o6) 3
>
> So your definition for rho_0 could be
>
> rho_0(k,L,Cn2) := (1.46*k^2*integrate(Cn2(l),l,0,L))^(-3/5)$
>
> instead of
>
> rho_0(k,L,Cn2) := block([k:k,L:L,Cn2:Cn2],(1.46*k^2*integrate(Cn2(l),l,0,L))^(-3/5)) $
>
> and similarly for all of the other functions, since none of them
> actually bind anything.
>
> Transcript:
>
> (%i12) rho_0(k,L,Cn2) := (1.46*k^2*integrate(Cn2(l),l,0,L))^(-3/5)$
>
> (%i13) rho_0(1,2,lambda([x], 1));
> (%o13) .5257391142650575
> (%i14) rho_0(k,L,Cn2) := block([k:k,L:L,Cn2:Cn2],(1.46*k^2*integrate(Cn2(l),l,0,L))^(-3/5)) $
>
> (%i15) rho_0(1,2,lambda([x], 1));
> (%o15) .5257391142650575
>
>
> As for the second question, you probably don't want any of the
> integrate calls quoted, but maybe it'll become more obvious once you've
> cleaned up the blocks everywhere.
>
>
> Rupert
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969