[Date Index]
[Thread Index]
[Author Index]
Re: Pattern Matching for Exponentials
*To*: mathgroup at smc.vnet.net
*Subject*: [mg67508] Re: [mg67502] Pattern Matching for Exponentials
*From*: "Carl K. Woll" <carlw at wolfram.com>
*Date*: Thu, 29 Jun 2006 00:09:11 -0400 (EDT)
*References*: <200606280752.DAA03521@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Rick Eller wrote:
> I am looking for a pattern-matching replacement rule which will
> transform exponential functions of the form exp(n i t) into
> (1/(n^2-1))exp(n i t) where i = sqrt[-1]. For example, exp(2 i t)
> should convert to (1/3)exp(2 i t). I've tried the following code without
> success :
>
> In: Exp[2 i t] /. Exp[n_ i t] -> Exp[n i t]/(n^2-1)
>
> Out: e^2 i t
>
> I would appreciate any suggestions as to how this code should be
> modified.
>
> Thanks,
>
> Rick Eller
In cases where pattern matching does not work as expected, you should
check the FullForm of the expression:
In[5]:= FullForm[Exp[2 I t]]
Out[5]//FullForm= Power[E, Times[Complex[0, 2], t]]
Your factor of 2 is absorbed into Complex. Integer, rational and inexact
numbers get absorbed into Complex, and in these cases the following will
work:
In[6]:= Exp[2 I t] /. Exp[Complex[0, n_] t] :> 1/(n^2 - 1) Exp[n I t]
Out[6]= (1/3)*E^(2*I*t)
If n is an exact number other than an integer or rational, such as
Sqrt[3], then you will need to work a bit harder:
In[8]:= Exp[Sqrt[3] I t] /.
Exp[f_. Complex[0, n_] t] :> 1/((f n)^2 - 1) Exp[f n I t]
Out[8]= (1/2)*E^(I*Sqrt[3]*t)
This latter rule should work in all cases.
Carl Woll
Wolfram Research
Prev by Date:
**Re: Pattern Matching for Exponentials**
Next by Date:
**RE: Viewing animations also on RealTime3D**
Previous by thread:
**Re: Pattern Matching for Exponentials**
Next by thread:
**Re: Pattern Matching for Exponentials**
| |