       Re: ExpToTrig with Real Numbers

• To: mathgroup at smc.vnet.net
• Subject: [mg63347] Re: [mg63334] ExpToTrig with Real Numbers
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Sat, 24 Dec 2005 16:02:56 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Clear[approx];
approx[expr_, n_:14]:=
expr/.x_?NumericQ:>Round[10^n*x]/10.^n;

expr=(-0.2624844042359744*I)*
Cos[0.9512492197250393*t]+
(0.26248440423597375*I)*
Cos[0.9512492197250397*t]-
0.2624844042359744*
Sin[0.9512492197250393*t]-
0.26248440423597375*
Sin[0.9512492197250397*t];

approx[expr]//Chop

-0.52496880847194*Sin[0.95124921972504*t]

Bob Hanlon

>
> From: "Blimbaum, Jerry CIV NSWC PC" <jerry.blimbaum at navy.mil>
To: mathgroup at smc.vnet.net
> Date: 2005/12/24 Sat AM 07:18:59 EST
> Subject: [mg63347] [mg63334] ExpToTrig with Real Numbers
>
>
> A calculation gives me the following as a part of the output that I see
> on the screen: (i = Imaginary)
>
> -0.262484 i  Exp[-0.951249 i t] +   0.262484 i Exp[0.951249 i t]
>
> I want to apply ExpToTrig and , of course, end up with 0 for the Cosine
> part and - .262484*2  Sin [0.951249] for the Sine part ...
>
> instead I get  (which I decided to look at output with InputForm)
>
> (-0.2624844042359744*I)*Cos[0.9512492197250393*t] +
> (0.26248440423597375*I)*Cos[0.9512492197250397*t] -
>  0.2624844042359744*Sin[0.9512492197250393*t] -
> 0.26248440423597375*Sin[0.9512492197250397*t]
>
> I can see from this that the coefficients and exponent numbers are very
> close but not identical  although , I think, in theory they should be.
> I'm not worried about the 10th decimal place.    How do i get the result
> I want in a general way?
>
>
> thanks....jerry blimbaum
>
>
>

```

• Prev by Date: Re: Pattern matching at bottom depth
• Next by Date: Re: Questions regarding MatrixExp, and its usage
• Previous by thread: Re: ExpToTrig with Real Numbers
• Next by thread: RealValued functions and derivatives