From: israel@math.ubc.ca (Robert Israel)
Newsgroups: sci.math.symbolic
Subject: Re: Quick Question on Maple programming.
Date: 2 Apr 1996 20:14:39 GMT
In article <31622E05.41C6@fisher.stats.uwo.ca>, Young Ho Cheong writes:
|> Let B:=(b0,b1,b2,b3,b4.b5,.....) be a vector(or list).
|> And A[k]=sum(B[k-r]*A[r],r=0..k-1)/(2*k) where A[0]=a0.
|> Hence if I input B in procedure I want to get A:=(A[0],A[1],A[2],....)
|> which is also vector(or list).
You can have a table T with an entry T[0], but not a vector or list.
Since you asked for a vector or list, I'll use them, but note that if
A = [a0, a1, ...] then a0 = A[1], not A[0].
My procedure will return either a vector or list, the same type as the
argument B.
> myproc := proc(B:{list,vector})
local r,k,t,n,A;
n := linalg[vectdim](B);
A[1] := a0;
for k from 2 to n do
A[k] := sum(B[k-r]*A[r+1],r = 0 .. k-2)/(2*k-2)
od;
t := [seq(A[k],k = 1 .. n)];
if type(B,vector) then linalg[vector](t) else t fi
end;
> myproc([b0, b1, b2, b3]);
2
[a0, 1/2 b1 a0, 1/4 b2 a0 + 1/8 b1 a0,
2
1/6 b3 a0 + 1/12 b2 b1 a0 + 1/6 b1 (1/4 b2 a0 + 1/8 b1 a0)]
> myproc(vector([b0,b1,b2]));
2
[ a0, 1/2 b1 a0, 1/4 b2 a0 + 1/8 b1 a0 ]
--
Robert Israel israel@math.ubc.ca
Department of Mathematics (604) 822-3629
University of British Columbia fax 822-6074
Vancouver, BC, Canada V6T 1Y4
==============================================================================
Date: Thu, 4 Apr 96 10:49:38 CST
From: rusin (Dave Rusin)
To: youngho@fisher.stats.uwo.ca
Subject: Re: Quick Question on Maple programming.
Newsgroups: sci.math.symbolic
In article <31622E05.41C6@fisher.stats.uwo.ca> you write:
>Now I am programming something in Maple .
>But I have in trouble in doing some kind of recurion.
>Here is what I want to get:
>
>
>Let B:=(b0,b1,b2,b3,b4.b5,.....) be a vector(or list).
>And A[k]=sum(B[k-r]*A[r],r=0..k-1)/(2*k) where A[0]=a0.
>Hence if I input B in procedure I want to get A:=(A[0],A[1],A[2],....)
>which is also vector(or list).
Are your ranges really right? It appears b0 never affects your
computation.
One approach is a little more slick theory than it is computation.
Observe that if we multiply the above equation by 2*k*X^k (where X
is a formal variable) and sum over all k, we get
2*X*(sum(A[k]*k*X^(k-1), k=0..infinity) =
= sum(sum(B[k-r]*A[r]*X^k, k=r+1..infinity), r=0..infinity)
In the inner sum, if we let s=k-r, we have
A[r]*X^r*sum(B[s]*X^s, s=1..infinity)
So if we define power series
BigB(X) = sum(B[s]*X^s, s=1..infinity)
and
BigA(X) = sum(A[s]*X^r, r=0..infinity)
then your defining property becomes
2*X*diff(BigA(X),X) = BigA(X)*BigB(X)
If BigA and BigB represent _convergent_ power series, this means
BigA is the powerseries of a solution to the equation
f'/f = g/2x
where g is the function for which BigB is the power series. Thus
f is a constant multiple of exp(int(g/2x, x)) = x^(b0/2) * exp( int(h, x)),
where h(x) = (g(x)-g(0))/(2x) (that is, I pulled out the one term in
g/2x which was not a positive power of x).
Thus if the B[s] are known to follow some sort of pattern, one can
(sometimes) deduce a pattern for the A[s] by using this
differential-equations argument.
dave