Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Periodic function Roots

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58406] Re: Periodic function Roots
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Fri, 1 Jul 2005 02:01:58 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, England
  • References: <da0bka$fkj$1@smc.vnet.net> <da0gq1$qnb$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Valeri Astanoff wrote:
> An example of what i do in such a case:
> 
> In[1]:=f[x_]:=Cos[x]+.5 Cos[2x]+.25 Cos[3x]+2.5 Cos[4x]
> 
> In[2]:=t=Table[FindRoot[f[x] == 0,{x,u}],{u,0.1,2Pi,0.1}];
> 
> In[3]:=Union[t,SameTest -> (Abs[(x/.#2)-(x/.#1)]<10^-5&)]
> 
> Out[3]=
> {{x -> -0.51129},{x -> 0.51129},{x -> 1.20136},
> {x -> 1.91222},{x -> 2.81887},{x -> 3.46432},
> {x -> 4.37096},{x -> 5.08183},{x -> 5.7719}}
> 
> 
> v.a.
> 
Drawing on the work of Valeri, here is another approach using *Reduce* 
and several other command depending of you intend to do with the 
solutions retuned by *Reduce*.

In[1]:=
f[x_] := Cos[x] + (1/2)*Cos[2*x] + (1/4)*Cos[3*x] +
    (5/5)*Cos[4*x]

In[2]:=
Reduce[f[x] == 0, x]

Out[2]=
C[1] â?? Integers &&
   (x == -2*ArcTan[Sqrt[Root[11 - 126*#1 + 260*#1^2 -
            114*#1^3 + #1^4 & , 1]]] + 2*Pi*C[1] ||
    x == 2*ArcTan[Sqrt[Root[11 - 126*#1 + 260*#1^2 -
            114*#1^3 + #1^4 & , 1]]] + 2*Pi*C[1] ||
    x == -2*ArcTan[Sqrt[Root[11 - 126*#1 + 260*#1^2 -
            114*#1^3 + #1^4 & , 2]]] + 2*Pi*C[1] ||
    x == 2*ArcTan[Sqrt[Root[11 - 126*#1 + 260*#1^2 -
            114*#1^3 + #1^4 & , 2]]] + 2*Pi*C[1] ||
    x == -2*ArcTan[Sqrt[Root[11 - 126*#1 + 260*#1^2 -
            114*#1^3 + #1^4 & , 3]]] + 2*Pi*C[1] ||
    x == 2*ArcTan[Sqrt[Root[11 - 126*#1 + 260*#1^2 -
            114*#1^3 + #1^4 & , 3]]] + 2*Pi*C[1] ||
    x == -2*ArcTan[Sqrt[Root[11 - 126*#1 + 260*#1^2 -
            114*#1^3 + #1^4 & , 4]]] + 2*Pi*C[1] ||
    x == 2*ArcTan[Sqrt[Root[11 - 126*#1 + 260*#1^2 -
            114*#1^3 + #1^4 & , 4]]] + 2*Pi*C[1])

In[3]:=
sols = N[%]

Out[3]=
C[1] â?? Integers &&
   (x == -0.6455013610404079 + 6.283185307179586*
       C[1] || x == 0.6455013610404079 +
      6.283185307179586*C[1] ||
    x == -1.2524776552773014 + 6.283185307179586*
       C[1] || x == 1.2524776552773014 +
      6.283185307179586*C[1] ||
    x == -1.828145008678062 + 6.283185307179586*C[1] ||
    x == 1.828145008678062 + 6.283185307179586*C[1] ||
    x == -2.9529034404768435 + 6.283185307179586*
       C[1] || x == 2.9529034404768435 +
      6.283185307179586*C[1])

In[4]:=
sols /. C[1] -> 0

Out[4]=
x == -0.6455013610404079 || x == 0.6455013610404079 ||
   x == -1.2524776552773014 ||
   x == 1.2524776552773014 ||
   x == -1.828145008678062 || x == 1.828145008678062 ||
   x == -2.9529034404768435 || x == 2.9529034404768435

In[5]:=
ToRules[%]

Out[5]=
Sequence[{x -> -0.6455013610404079},
   {x -> 0.6455013610404079},
   {x -> -1.2524776552773014},
   {x -> 1.2524776552773014},
   {x -> -1.828145008678062}, {x -> 1.828145008678062},
   {x -> -2.9529034404768435},
   {x -> 2.9529034404768435}]

Best regards,
/J.M.


  • Prev by Date: Re: Integrate and Boole problems
  • Next by Date: Re: poly question
  • Previous by thread: Re: Periodic function Roots
  • Next by thread: Explicit solution to Root[]