Re: Testing that the elements are a list are exponential
- To: mathgroup at smc.vnet.net
- Subject: [mg32221] Re: [mg32178] Testing that the elements are a list are exponential
- From: "Dr. Reinhard Simonovits" <Reinhard.Simonovits at kfunigraz.ac.at>
- Date: Mon, 7 Jan 2002 03:16:49 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Dear Guillermo,
One solution might be
In[41]:=Clear[F,s, a,x,t];
F[x_List?( And @@ (Or[ # === 0, # === 0.,
MemberQ[{#}, Exp[___],\[Infinity]] ]&/@ # )&)] :=
x/.a_*E^(s_*t) -> (a*(-1 + E^(s*t)))/s;
F[_]:= Print["No match"];
With your lst = { 0, 1.4 Exp [-3 t] + 1.2 Exp [- t], 0, 0.24 Exp [a t]}
In[44]:=F[lst]//InputForm
Out[44]//InputForm=
{0., -0.4666666666666666*(-1 + E^(-3*t)) -
1.199999999999999*(-1 + E^(-t)), 0,
(0.2399999999999999*(-1 + E^(a*t)))/a}
In[45]:= F[{0.,5 Exp[u t],k} ]
"No match"
?(...) checks whether a list element from your list is 0 or 0.(MVersion3.0)
or contains an exponential function.
More precise specification from your side could improve the pattern
matching of exponential functions.
So this is a rather rude approach.
Best wishes, Reinhard
I
>I have a make a function where all element of a list should
>be exponentials or cero.
>Here is an example
>
>lst1 = { 0, 1.4 Exp [-3 t] + 1.2 Exp [- t], 0, 0.24 Exp [a t]}
>
>F[x_] := x /. a_*E^(s_*t) -> (a*(-1 + E^(s*t)))/s
>
>It works
>
>F[lst1]
>
>But I need define F[x_?Test] where ?Test check that all element of list are
>exponentials or cero. How I can build the test?
********************************************
Dr. Reinhard Simonovits
Handelsakademie | Karl Franzens University
Math Department | Inst. of Th. Physics
Grazbachgasse 71 | Universitaetsplatz 5
A-8010 Graz, Austria
Email: Reinhard.Simonovits at uni-graz.at
*********************************************