Re: Extract coefs. and exponents from a list . Package problem

• To: mathgroup at smc.vnet.net
• Subject: [mg30731] Re: Extract coefs. and exponents from a list . Package problem
• From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
• Date: Sat, 8 Sep 2001 02:56:27 -0400 (EDT)
• Organization: Universitaet Leipzig
• References: <9nal4a\$nos\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi,

BeginPackage["test`test`"];

ExtractCoef::usage = "ExtractCoef[test]";

Begin["`Private`"];

ExtractCoef[list_, t_] :=

Transpose[Cases[list, _*Exp[_*t], Infinity] /. a_*Exp[b_*t] :> {a, b}]

End[];

EndPackage[]

???

Regards
Jens

Guillermo Sanchez wrote:
>
> Dear group
> (*I wish extract the coeffs and the exponents from expresion as follow*)
>
> list1=0.1 Exp[-0.3 t]+0.2 Exp[-0.1 t]+0.4 Exp[-0.4 t];
>
> (*This function works*)
>
> ExtractCoef1[list_]:=
>   Block[{f,g,a,b},f[a__]:={a};
>     g[b__]:={b};{(#1/.a_*Exp[b_*t]\[Rule]a&)/@
>         f@@list,(#1/.a_*Exp[b_*t]\[Rule]b&)/@g@@list}]
>
> ExtractCoef1[list1]
>
> (*out[]:{{0.4`,0.1`,0.2`},{-0.4`,-0.3`,-0.1`}}*)(*it works*)
>
> (*But, if I use this function inside a package it doesn`t work*)
>
> BeginPackage["test`test`"];
>
> ExtractCoef::usage="ExtractCoef[test]";
>
> Begin["`Private`"];
>
> ExtractCoef[list_]:=
>   Block[{f,g,a,b},f[a__]:={a};
>     g[b__]:={b};{(#1/.a_*Exp[b_*t]\[Rule]a&)/@
>         f@@list,(#1/.a_*Exp[b_*t]\[Rule]b&)/@g@@list}]
> End[];
> Protect[ExtractCoef];
> EndPackage[];
>
> ExtractCoef[list1](*It doesn´t work*)
>
> (* question 1: I wist fix this problem,any help?,
> question 2: Could any body build a expresion easier?*)

```

• Prev by Date: Mathematica installation in a lab setting
• Next by Date: Re: newbie: computing rational numbers and decimal
• Previous by thread: Extract coefs. and exponents from a list . Package problem
• Next by thread: Re: Extract coefs. and exponents from a list . Package problem