Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Semi-symbolically Semi-numerically

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113478] Re: Semi-symbolically Semi-numerically
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Sat, 30 Oct 2010 04:38:21 -0400 (EDT)
  • References: <201010260935.FAA29594@smc.vnet.net>

Sam,

here is one way:

In[5]:= (1. Cos[theta]^8 - 28. Cos[theta]^6 Sin[theta]^2 -
    28. Cos[theta]^2 Sin[theta]^6 + 1. Sin[theta]^8 +
    4.375 Sin[2 theta]^4 /. x_Real :>
    With[{ratnl = Rationalize[x]},
     ratnl /; ratnl == x]) // FullSimplify

Out[5]= Cos[8 theta]

That is, rationalize those real numbers for which the rational
representation is exact,
then simplify.

Regards,
Leonid

On Tue, Oct 26, 2010 at 1:35 PM, Sam Takoy <sam.takoy at yahoo.com> wrote:

> Hi,
>
> I'm working on a project where certain elements need to be computed
> numerically. Not surprisingly, some simplifications that work
> symbolically, don't work with floating numbers. But some still do, e.g.
> 1.0 Sin[a]^2 + 1.0 Cos[a]^2 // Simplify is 1.0;
>
> Is there a way to make the example that follows, that starts with Cos[8
> theta] then goes to Cartesian coordinates and back to polar, to work as
> well as the trivial trig example above?
>
> Many thanks in advance,
>
> Sam
>
>
> toCart = theta -> ArcTan[x, y];
> toPolar = {x -> Cos[theta], y -> Sin[theta]};
> help = {Cos[ArcTan[x, y]] -> x/Sqrt[x^2 + y^2],
>    Sin[ArcTan[x, y]] -> y/Sqrt[x^2 + y^2]};
>
> ((Cos[8 theta] /. toCart // TrigExpand) /. help // FullSimplify) /.
>   toPolar // Simplify
> ((1.0 Cos[8 theta] /. toCart // TrigExpand) /. help //
>     FullSimplify) /. toPolar // Simplify
>
> Out[1357]= Cos[8 theta]
>
> Out[1358]=
> 1. Cos[theta]^8 - 28. Cos[theta]^6 Sin[theta]^2 -
>  28. Cos[theta]^2 Sin[theta]^6 + 1. Sin[theta]^8 +
>  4.375 Sin[2 theta]^4
>
>


  • Prev by Date: Re: Determining the root of the characteristic equation for time
  • Next by Date: Re: Determining the root of the characteristic equation
  • Previous by thread: Semi-symbolically Semi-numerically
  • Next by thread: How to find the eigenvalues/eigenfunctions of a differential linear