Re: Re: Re: Why can't Mathematica find this root?
- To: mathgroup at smc.vnet.net
- Subject: [mg38440] Re: [mg38417] Re: [mg38362] Re: Why can't Mathematica find this root?
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sun, 15 Dec 2002 02:10:12 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On Saturday, December 14, 2002, at 05:20 PM, Daniel Lichtblau wrote:
> Konrad Den Ende wrote:
>>
>>> No, you don't. There are infinitely many roots, of which Mathematica
>>> gives
>>> you only three: -Pi/2, 0, and Pi/2.
>>
>> Actually, you get five different roots, not three. Nevertheless -
>> point
>> taken.
>> I ment of course that i'd like Mathematica to give me ALL the roots
>> on form:
>> angle + (period * n). I'll try to be more exact the next time.
>>
>>> Didn't you notice Mathematica's comment that, since inverse
>>> functions were
>>> being used, some solutions might not be found? That's the
>>> explanation.
>>
>> Yes, i did. I wonder why it's the ONLY method used by Mathematica. It
>> feels
>> pretty bad to know that the program "misses" some simple roots. I
>> don't
>> wonder
>> "what kind of algorithm gave that", rather "why do they use only that
>> algorithm".
>>
>> I appologize if my question caused any trouble by it's "fuzziness".
>>
>> --
>> V?nligen
>> Konrad
>> -------------------
>
> I did not really understand at first the nature of the question. Now
> that I do I'll take a stab at it. Under Solve>Further Examples>"Getting
> infinite solution sets for some equations" in the Help Browser, there
> is
> code to do something called "GeneralizeSolve". It is based on finding
> periodic inverses to various known functions, and takes advantage of
> the
> fact that Solve will find solutions in terms of these inverse
> functions.
> It does not quite work directly on your problem for the simple reason
> that e.g. ArcSin[0] will evaluate to 0. So we make it work by solving
> f'[x]==a and substituting a->0 afterward.
>
> Here is the code in question.
>
> arctrigs = {ArcSin, ArcCos, ArcCsc, ArcSec, ArcTan, ArcCot, ArcSinh,
> ArcCosh,
> ArcCsch, ArcSech, ArcTanh, ArcCoth};
>
> periods = {2*Pi, 2*Pi, 2*Pi, 2*Pi, Pi, Pi, 2*I*Pi,
> 2*I*Pi, 2*I*Pi, 2*I*Pi, I*Pi, I*Pi};
>
> (* We use n to denote an arbitrary integer *)
>
> Generalize[f_[x_], n_] :=
> f[x] + nperiods[[Position[arctrigs, f][[1, 1]]]] /; MemberQ[arctrigs,
> f]
>
> Generalize[Log[x_],n_]:=Log[x]+2\[Pi]\[ImaginaryI]n
>
> Generalize[ProductLog[x_],n_]:=ProductLog[n,x]
>
> Generalize[x___, n_] := x
>
> GeneralizedSolve[eqns_, vars_] := Generalize[#, n] & //@ Solve[eqns,
> vars]
>
> In[12]:=
> GeneralizedSolve[f'[x]==a,x]/. a->0
>
> Solve::ifun: Inverse functions are being used by Solve, so some
> solutions may \
> not be found.
>
> Out[12]=
> {{x -> -((2*Pi)/3) - 2*n*Pi}, {x -> (2*Pi)/3 + 2*n*Pi},
> {x -> -(Pi/3) - 2*n*Pi}, {x -> Pi/3 + 2*n*Pi},
> {x -> -Pi - 2*n*Pi}, {x -> Pi + 2*n*Pi},
> {x -> -2*n*Pi}, {x -> 2*n*Pi}}
>
> A minor inconvenience is that some solutions may be listed more than
> once e.g. the last two are equivalent if we regard n as ranging over
> all
> integers.
>
>
> Daniel Lichtblau
> Wolfram Research
>
>
>
This last "minor inconvenience" can be dealt with as follows:
g[x_, y_] := TrueQ[Simplify[Element[x,
Integers], Element[y, Integers]] &&
Simplify[Element[y, Integers], Element[x, Integers]]]
l = GeneralizedSolve[Derivative[1][f][x] == a, x] /. a -> 0
Solve::ifun:Inverse functions are being used by Solve, so some
solutions may \
not be found.
{{x -> -((2*Pi)/3) - 2*n*Pi}, {x -> (2*Pi)/3 + 2*n*Pi},
{x -> -(Pi/3) - 2*n*Pi}, {x -> Pi/3 + 2*n*Pi},
{x -> -Pi - 2*n*Pi}, {x -> Pi + 2*n*Pi}, {x -> -2*n*Pi},
{x -> 2*n*Pi}}
Union[l, SameTest -> (g[x /. #1, x /. #2] & )]
{{x -> -2*n*Pi}, {x -> -Pi - 2*n*Pi},
{x -> -((2*Pi)/3) - 2*n*Pi}, {x -> -(Pi/3) - 2*n*Pi},
{x -> Pi/3 + 2*n*Pi}, {x -> (2*Pi)/3 + 2*n*Pi},
{x -> Pi + 2*n*Pi}}
(One could of course write a version of GeneralizedSolve that does this
automatically).
Andrzej Kozlowski
Yokohama, Japan
http://www.mimuw.edu.pl/~akoz/
http://platon.c.u-tokyo.ac.jp/andrzej/