MathGroup Archive 2009

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

Search the Archive

Re: Re: Wrong Simplify[] Answer for

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104570] Re: [mg104513] Re: Wrong Simplify[] Answer for
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Wed, 4 Nov 2009 01:34:33 -0500 (EST)
  • Reply-to: hanlonr at cox.net

a = Cos[x]^2 - Sin[x]^2;
b = Cos[x]^4 - Sin[x]^4;

Table[a - b, {x, -10, 10}] // Simplify

{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

Note what happens when you use precision greater than machine precision

Off[N::meprec]

Table[a - b, {x, -10, 10}] // N[#, 20] &

{0.*10^-249,0.*10^-249,0.*10^-249,0.*10^-249,0.*10^-249,0.*10^-249,0.*10^-249,0.*10^-250,0.*10^-250,0.*10^-250,0,0.*10^-250,0.*10^-250,0.*10^-250,0.*10^-249,0.*10^-249,0.*10^-249,0.*10^-249,0.*10^-249,0.*10^-249,0.*10^-249}


Bob Hanlon

---- Lawrence Teo <lawrenceteo at yahoo.com> wrote: 

=============
Hi all,

Thanks for the insight. So Simplify[] in Mathematica is right.
But why I observe small delta if I subtract the two expressions with // N?
Is it because of machine precision related limitation?

a = Cos[x]^2 - Sin[x]^2
b = Cos[x]^4 - Sin[x]^4
Table[a - b, {x, -10, 10}] // N

Return small delta...
\!\({6.938893903907228`*^-17, 6.245004513516506`*^-17, 0.`,
    0.`, 7.025630077706069`*^-17, 0.`, 0.`, 3.854338723185968`*^-17,
0.`,
    1.1102230246251565`*^-16, 0.`, 1.1102230246251565`*^-16, 0.`, \
3.854338723185968`*^-17, 0.`, 0.`, 7.025630077706069`*^-17, 0.`, 0.`,
\
6.245004513516506`*^-17, 6.938893903907228`*^-17}\)



On Oct 31, 2:50 pm, Peter Breitfeld <ph... at t-online.de> wrote:
> Lawrence Teo wrote:
> > We know that Simplify[Cos[x]^2-Sin[x]^2] -> Cos[2 x]
> > But why Simplify[Cos[x]^4-Sin[x]^4] -> Cos[2 x] too?
>
> > Doing subtraction between the two expressions will give small delta.
> > This is enough to prove that the two expression shouldn't be the same.
>
> > Can anyone give me any insight? Thanks.
>
> it's simply true, because:
>
> cos^4 x - sin^4 x = (cos^2 x - sin^2 x)(cos^2 x + sin^2 x)
> = (cos^2 x - sin^2 x) * 1 = cos 2x
>
> --
> _________________________________________________________________
> Peter Breitfeld, Bad Saulgau, Germany --http://www.pBreitfeld.de



  • Prev by Date: Cylinder cylinder intersection: Design of a starter crank.
  • Next by Date: Re: Beginning syntax problems
  • Previous by thread: Re: Re: Wrong Simplify[] Answer for
  • Next by thread: Re: Distribution of state occupancies in a multistate Markov model