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

• To: mathgroup at smc.vnet.net
• Subject: [mg20411] Re: [mg20320] Solving trig equations - Tan[x] = Sqrt
• 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
>
> .. 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:= InputForm[soln = Solve[Tan[x + kk*Pi] == Sqrt, x]]
Out//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:= InputForm[Select[
Flatten[Table[soln, {kk,-2,2}]], (0<=#[]<2*Pi)&]]
Out//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.

{ArcCos,2}, {ArcSec,2}, {ArcTan,1},
{ArcCot,1}, {ArcSinh, 2*I}, {ArcCosh,2*I},
{ArcCosh,2*I}, {ArcSech,2*I},
{ArcTanh,I}, {ArcCoth,I}};
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,x] is not expressed in terms of the above
functions (because ArcTan[Sqrt] evaluates to something else). We get
around that by solving symbolically and plugging in Sqrt later, as
below. Again we form a table, selecting the solutions we want.

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

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

In:= InputForm[fullsol = Select[Flatten[Table[soln,
Evaluate[{ivar,-2,2}]]], (0<=#[]<2*Pi)&]]
Out//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:= InputForm[soln = generalize //@ Solve[E^(2*x)-2*E^x+2 == 0, x]]
Out//InputForm=
{{x -> 2*I*K\$13*Pi + Log[1 - I]}, {x -> 2*I*K\$14*Pi + Log[1 + I]}}

Check the results:

In:= Simplify[E^(2*x)-2*E^x+2==0 /. soln,
Element[Variables[x/.soln],Integers]]
Out= {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