Extract coefs. and exponents from a list . Package problem
- To: mathgroup at smc.vnet.net
- Subject: [mg30684] Extract coefs. and exponents from a list . Package problem
- From: guillerm at aida.usal.es (Guillermo Sanchez)
- Date: Sat, 8 Sep 2001 02:22:27 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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?*)