Double integral of a function (Beginners Question)
Subject: Double integral of a function (Beginners Question)
From: Rupert Swarbrick
Date: Mon, 07 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20100607/80dfe90d/attachment.pgp>