MathGroup Archive 1999

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

Search the Archive

Re: Solving trig equations - Tan[x] = Sqrt[3]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20411] Re: [mg20320] Solving trig equations - Tan[x] = Sqrt[3]
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Tue, 26 Oct 1999 00:32:59 -0400
  • References: <199910160020.UAA26350@smc.vnet.net.>
  • Sender: owner-wri-mathgroup at wolfram.com

James MacDonald wrote:
> 
> I'm using Mathematica v3, and want to solve an equation of the form:
> 
> Tan[x] == Sqrt[3]
> 
> .. for values of x, in degrees, between 0 and 360. I think that I can pull
> out 60, but I'd also like to be able to get 240, and can't seem to do it.
> 
> Is there an argument to Solve (or an alternative function/package) that will
> allow me to specify the range of roots that I'd like to find?
> 
> --
> James MacDonald; Acorn/NeXT/Ally McBeal
> 
> We are John Cage of Borg. Assimilation troubles us; we have to take a moment.
> Poughkeepsie.

One way is to put an explicit constant into the equation as a
placeholder for a periodic solution.

In[56]:= InputForm[soln = Solve[Tan[x + kk*Pi] == Sqrt[3], x]]
Out[56]//InputForm= {{x -> Pi/3 - kk*Pi}}

Now form a table with various integer values for the constant, then
select those between 0 and 2*Pi.

In[57]:= InputForm[Select[
        Flatten[Table[soln, {kk,-2,2}]], (0<=#[[2]]<2*Pi)&]]         
Out[57]//InputForm= {x -> (4*Pi)/3, x -> Pi/3}

If you like fiddling with periodic multivalued results for the inverse
elementary functions, here is code I once wrote for a more general
approach.

arctrigheads = {{ArcSin,2}, {ArcCos,2},
	{ArcCos,2}, {ArcSec,2}, {ArcTan,1},
	{ArcCot,1}, {ArcSinh, 2*I}, {ArcCosh,2*I},
	{ArcCosh,2*I}, {ArcSech,2*I},
	{ArcTanh,I}, {ArcCoth,I}};
Do[	arcTrigQ[arctrigheads[[j,1]]] = True; 
	mult[arctrigheads[[j,1]]] = arctrigheads[[j,2]], 
	{j,Length[arctrigheads]}]; 
generalize[(f_)[x_]] /; TrueQ[arcTrigQ[f]] := 
	f[x] + mult[f]*Pi*Unique[K]
generalize[Log[x_]] := Log[x] + 2*Pi*I*Unique[K]
generalize[ProductLog[x_]] := ProductLog[Unique[K], x]
generalize[x___] := x
Off[Solve::ifun]

This will not work directly because the solution for
Solve[Tan[x]==Sqrt[3],x] is not expressed in terms of the above
functions (because ArcTan[Sqrt[3]] evaluates to something else). We get
around that by solving symbolically and plugging in Sqrt[3] later, as
below. Again we form a table, selecting the solutions we want.

In[83]:= InputForm[soln =
        (generalize //@ Solve[Tan[x]==y, x]) /. y->Sqrt[3]]
Out[83]//InputForm= {{x -> Pi/3 + K$8*Pi}}

In[84]:= ivar = First[Variables[x/.soln]]
Out[84]= K$8

In[85]:= InputForm[fullsol = Select[Flatten[Table[soln,
        Evaluate[{ivar,-2,2}]]], (0<=#[[2]]<2*Pi)&]]
Out[85]//InputForm= {x -> Pi/3, x -> (4*Pi)/3}

If you require the usual list-of-lists form of Solve result, you can
then do

Map[List, fullsol]


Here is an example I rather like.

In[91]:= InputForm[soln = generalize //@ Solve[E^(2*x)-2*E^x+2 == 0, x]]
Out[91]//InputForm= 
{{x -> 2*I*K$13*Pi + Log[1 - I]}, {x -> 2*I*K$14*Pi + Log[1 + I]}}

Check the results:

In[92]:= Simplify[E^(2*x)-2*E^x+2==0 /. soln,
Element[Variables[x/.soln],Integers]]
Out[92]= {True, True}


Daniel Lichtblau
Wolfram Research


  • Prev by Date: Re: Font problems running remotely
  • Next by Date: Re: how to avoid numeric error
  • Previous by thread: Solving trig equations - Tan[x] = Sqrt[3]
  • Next by thread: MathLink AppleScript module?