Subject: Function evaluates wrong when called from dblint
From: Neilen Marais
Date: Mon, 13 Jun 2011 16:31:02 +0200
Hi,
On Sun, Jun 12, 2011 at 7:36 PM, Robert Dodier <robert.dodier at gmail.com> wrote:
> On 6/9/11, Neilen Marais <nmarais at gmail.com> wrote:
>
>> (%i9) dblint(f2, lambda([x],-1/2), lambda([x], 1/2), -1/2, 1/2);
>> [0.0,0.0,6.304713613808152*10^58,1.4850279263678455*10^-64,3.141592653589793-1.0*acos((1.4850279263678455*10^-64)/r),0.0]
>> (%o9) 7.0052373486757241*10^55
>
> I nominate this one for the Maxima "unintended consequences" hall of fame.
Haha :)
>
> There is a variable z in dblint and the repeated evaluation and
> substitution in f2 pulls in (courtesy of dynamic binding, i.e. non-lexical)
> whatever is the current value of z. Try tracing subst -- you'll see
> stuff like this:
> ?Enter subst [[1.529155181083518 = 1/2],
> ... that can't be good.
>
> If you rename z in expr, sublis, and f2 to zz or something like that,
> or rename z in dblint to something else, I think you'll get a different result.
OK, so the dblint function's implementation uses a variable called
'z', which is intefering with my definition of 'z'? I changed my
functions to use 'zz', and it indeed seems to be better!
Thanks
Neilen