Subject: Fwd: What am I doing wrong with this cycle?
From: Stavros Macrakis
Date: Fri, 19 Jul 2013 07:58:12 -0400
FYI The problem turned out to be a misunderstanding about the semantics of
f[i](x):=..., not integration.
-s
---------- Forwarded message ----------
From: Pyotr Ivanshin <pivanshin at gmail.com>
Date: Thu, Jul 18, 2013 at 9:07 PM
Subject: Re: [Maxima] What am I doing wrong with this cycle?
To: Stavros Macrakis <macrakis at alum.mit.edu>
Dear Stavros Macrakis!
Thank you very much.
The problem seems to bee solved.
Yes, as it happened, I really did not understand the semantics correctly.
The code
f[0](z,t):=rw5*z^k+rw5*t^k;
S:"ddc";
M[0]:5;
for j:1 thru slength(S) step 1 do (if charat(S, j)="a" then
(M[j]:M[j-1]-2, h[j]:funmake('lambda,['[z, t],
(M[j]+1)*(M[j]+2)*integrate(f[j-1](z,t), t)/2]),
f[j]:funmake('lambda, ['[z,t], -(1/4)*integrate(h[j](z, t)-h[j](t, z), z)]))
elseif charat(S, j)="b" then (M[j]:M[j-1]-2, h[j](z,t):funmake('lambda,
['[z,t], Mu*(M[j] +1)*(M[j]+2)*integrate(f[j-1](z,t), t)/2]),
f[j]:funmake('lambda, ['[z, t], (h[j](z,t)+h[j](t,z))/2]))
elseif charat(S, j)="c" then (M[j]:M[j-1]-1, f[j]:funmake('lambda, ['[z,t],
(-1/2)*(M[j]+1)*integrate(f[j-1](z,t), z)]))
elseif charat(S, j)="d" then (M[j]:M[j-1]-2, f[j]:funmake('lambda,
['[z,t],-(M[j]+1)*(M[j]+2)*integrate(integrate(f[j-1](z,t), z), t)]))
elseif charat(S, j)="e" then (M[j]:M[j-1]-1, f[j]:funmake('lambda,
['[z,t],-Mu*(M[j]+1)*f[j-1](z, t)]))
elseif charat(S, j)="f" then (M[j]:M[j-1]-1, f[j]:funmake('lambda,
['[z,t],(M[j]+1)*integrate(integrate(f[j-1](z,t), z), t)/Mu])));
does the job.
Thank you very much one more time. I feel myself obliged to pay you
something at least for the time wasted on me.
Best regards,
Pyotr Ivanshin
2013/7/18 Stavros Macrakis <macrakis at alum.mit.edu>
> It would be nice if you could supply a *minimal reproducible example *of
> the problem you're reporting. There's a lot going on in your code, and
> it's unreasonable to expect that we will guess what you intended.
>
> That said, are you sure you understand the semantics of f[j](x):=...
> correctly? The effect of that definition does *not* depend on the current
> value of j. For example:
>
> for i thru 2 do if i=1 then f[i](x):=23 else f[i](x):=45
>
> does *not *leave you with f[1](x):=23 and f[2](x):=45:
>
> dispfun(f) => f[i](x):=45
> f[1] => lambda([x],45)
> f[2] => lambda([x],45)
>
> Maybe you want something like
>
> for i thru 2 do if i=1 then f[i]:funmake('lambda,[ '[x], 23 ] )
> else f[i]:funmake('lambda,[ '[x], 45 ] )
>
> ? Just guessing...
>
> -s
>
>
> On Thu, Jul 18, 2013 at 3:59 AM, Pyotr Ivanshin <pivanshin at gmail.com>wrote:
>
>> The output of this program is simply wrong.
>>
>> f[0](z,t):=rw5*z^k+rw5*t^k;
>> S:"ddc";
>> M[0]:5;
>> for j:1 thru slength(S) step 1 do (if charat(S, j)="a" then
>> (M[j]:M[j-1]-2, h[j](z,t):=(M[j]
>> +1)*(M[j]+2)*integrate(f[j-1](z,t), t)/2, f[j](z,
>> t):=-(1/4)*integrate(h[j](z, t)
>> -h[j](t,
>> z), z))
>> elseif charat(S, j)="b" then (M[j]:M[j-1]-2, h[j](z,t):=Mu*(M[j]
>> +1)*(M[j]+2)*integrate(f[j-1](z,t), t)/2, f[j](z,
>> t):=(h[j](z,t)+h[j](t,z))/2)
>> elseif charat(S, j)="c" then (M[j]:M[j-1]-1, f[j](z,
>> t):=(-1/2)*(M[j]+1)*integrate(f[j
>> -1](z,t), z))
>> elseif charat(S, j)="d" then (M[j]:M[j-1]-2, f[j](z,
>> t):=-(M[j]+1)*(M[j]+2)*integrate(integrate(f[j
>> -1](z,t), z), t))
>> elseif charat(S, j)="e" then (M[j]:M[j-1]-1, f[j](z,
>> t):=-Mu*(M[j]+1)*f[j-1](z, t))
>> elseif charat(S, j)="f" then (M[j]:M[j-1]-1, f[j](z,
>> t):=(M[j]+1)*integrate(integrate(f[j
>> -1](z,t), z), t)/Mu)
>> );
>>
>> Even f[1] (z, t) equals wrong expression.
>>
>>
>> Would anybody be so kind as to show me my mistake?
>> _______________________________________________
>> Maxima mailing list
>> Maxima at math.utexas.edu
>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>
>
>