Re: A pattern matching problem
- To: mathgroup at smc.vnet.net
- Subject: [mg72544] Re: A pattern matching problem
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sat, 6 Jan 2007 03:38:30 -0500 (EST)
- References: <enksb3$9nt$1@smc.vnet.net>
Hi,
what is with
r = u[t + h] - 2*u[t] + u[t - h] + a2*u'[t + h/2] + 4*u'[t - h/4] + c*
u''[t + alfa*h]/12;
(Cases[r, u[_] |
Derivative[__][u][_], Infinity] /. {u[
arg_] :> {0, arg}, Derivative[i_][u][arg_] :> {i,
arg}}) /. {order_Integer, arg_} :> {order, D[arg, h]}
Regards
Jens
carlos at colorado.edu wrote:
> Here is an interesting challenge in pattern matching. Suppose
> you are given an algebraic-differential expression exemplified by
>
> r = u[t+h]-2*u[t]+u[t-h]+a^2*u'[t+h/2]+4*u'[t-h/4]+
> c*u''[t+alfa*h]/12;
>
> Here u[t] is a function of time t, assumed infinitely differentiable,
> h is a time interval, and primes denote derivatives wrt t.
> Relation r==0 is called a delay-differential equation, and is the
> basic stuff in delayed automatic control (h is the signal "lag").
>
> The function name u and the lag h are always symbolic.
> Function u and its derivatives appear linearly in r, while
> h always appears linearly in arguments.
> Coefficients of h may be numeric or symbolic.
> Coefficients of u & derivatives may be numeric or symbolic.
>
> The challenge: given r, get the coefficients of h as a 2D list,
> row-ordered by derivative order. Zero coefficients may be omitted.
> For the above r, it should return
>
> {{1,-1},{1/2,-1/4},{alfa}}
>
> Envisioned module invocation: clist=LagCoefficients[r,u,t,h,m]
> with m=max u-derivative order to be considered. Skeleton:
>
> LagCoefficients[r_,u_,t_,h_,m_]:=Module[ {clist={}},
> ??????
> Return[clist]];
>
> Any ideas for ?????
>
- Follow-Ups:
- Re: Re: A pattern matching problem
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: Re: A pattern matching problem