MathGroup Archive 2008

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

Search the Archive

Re: Re: How to simplify ArcCos[x/Sqrt[x^2+y^2]] to Pi/2-ArcTan[x/Abs[y]]?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91857] Re: [mg91834] Re: How to simplify ArcCos[x/Sqrt[x^2+y^2]] to Pi/2-ArcTan[x/Abs[y]]?
  • From: "Peng Yu" <pengyu.ut at gmail.com>
  • Date: Wed, 10 Sep 2008 05:09:59 -0400 (EDT)
  • References: <ga2po2$p77$1@smc.vnet.net> <200809091059.GAA28099@smc.vnet.net>

On Tue, Sep 9, 2008 at 5:59 AM, Roland Franzius <roland.franzius at uos.de> wrote:
> Peng Yu schrieb:
>> Hi,
>>
>> ArcCos[x/Sqrt[x^2+y^2]]
>>
>> and
>>
>> Pi/2-ArcTan[x/Abs[y]]
>>
>> are the same.
>>
>> But I can not get the first expression be simplified to the second
>> one. And the following command can not be simplified to zero in
>> mathematica as well.
>>
>> FullSimplify[ArcCos[x/Sqrt[x^2 + y^2]] - ( Pi/2 - ArcTan[x/Abs[y]]),
>>  Element[x, Reals] && Element[y, Reals]]
>>
>> I'm wondering if there is any walkaround to do this simplification.
>
> Try
>
> Assuming[x > 0 && y > 0,
>  FullSimplify[
>   TrigToExp[ArcCos[x/Sqrt[x^2 + y^2]] - (Pi/2 - ArcTan[x/Abs[y]])]]]
>
> (1/2)*I*(Log[1/(I*x + y)] + Log[I*x + y])
>
>
> Obviously Mathematica isn't making a guess to which leaf of the complex
> Log your algebraic complex travel history brought even if you arrived on
> the positive real line.

What I want is to simplify ArcCos[x/Sqrt[x^2 + y^2]] as Pi/2 -
ArcTan[x/Abs[y]]. The two expressions are the same for any real x and
y (maybe also true for complex x and y?).

The use of such manipulation is useful when I want to convert the
expression to CForm and eventually integrated in a C++ program, as the
second expression is less likely to under or overflow than the first
one. But I just don't find a way to do such manipulation in
Mathematica.

The more general question is how to manipulate an arithmetic
expression to make it less likely to over or underflow. Another
example is that the abs of a complex number is never computed as
sqrt(x*x+y*y), it is always computed as
 |x| *sqrt(1+std::pow(x/y,2)) if |x| >= |y|.
or
 |y| *sqrt(1+std::pow(y/x,2)) if |x| < |y|.

I doubt Mathematica could solve this problem in general. But can I
make it solve at least those particular cases?


  • Prev by Date: Re: Error in file / load entire notebook into memory
  • Next by Date: Re: Real and Complex Roots presented in a single plot
  • Previous by thread: Re: How to simplify ArcCos[x/Sqrt[x^2+y^2]] to Pi/2-ArcTan[x/Abs[y]]?
  • Next by thread: use vim to edit mathematica file