Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Very strange behaviour of ArcTan[]

99 views
Skip to first unread message

Alexey

unread,
Aug 17, 2009, 8:06:46 AM8/17/09
to
Hello,
I just have discovered some strange (buggy?) feature of ArcTan[]
function in Mathematica 5.2. Try the following;

In[72]:=
ArcTan[.5,$MachinePrecision]
ArcTan[.5]

Out[72]=
1.53947

Out[73]=
0.463648

The expression ArcTan[.5,$MachinePrecision] must (?) give an error but
in really gives some strange output without any error messages... What
do you think about this?

Louis Talman

unread,
Aug 18, 2009, 6:05:59 AM8/18/09
to

On Aug 17, 2009, at 6:06 AM, Alexey wrote:

> The expression ArcTan[.5,$MachinePrecision] must (?) give an error but
> in really gives some strange output without any error messages... What
> do you think about this?

I think you need to run

?ArcTan

and pay attention to what the syntax

ArcTan[x, y]

accomplishes.


--Lou Talman
Department of Mathematical and Computer Sciences
Metropolitan State College of Denver

<http://clem.mscd.edu/%7Etalmanl>

Pillsy

unread,
Aug 18, 2009, 6:06:42 AM8/18/09
to
On Aug 17, 8:06 am, Alexey <lehi...@gmail.com> wrote:

> I just have discovered some strange (buggy?) feature of ArcTan[]
> function in Mathematica 5.2. Try the following;

What you've discovered is that ArcTan has a definition for two
arguments where ArcTan[x, y] gives you ArcTan[y/x], but correctly
accounting for the signs of x and y. This is actually a pretty common
bit of functionality to have access to; in the C standard library
there's a two-argument function called atan2 that does the same thing,
for instance.

Cheers,
Pillsy

DrMajorBob

unread,
Aug 18, 2009, 6:07:15 AM8/18/09
to
Nothing wrong there at all.

t = ArcTan[0.5, $MachinePrecision]
Tan@t == $MachinePrecision/0.5

1.53947

True

u = ArcTan[0.5]
Tan@u == 0.5

0.463648

True

That's exactly what's supposed to happen.

Bobby

On Mon, 17 Aug 2009 07:06:56 -0500, Alexey <leh...@gmail.com> wrote:

> Hello,


> I just have discovered some strange (buggy?) feature of ArcTan[]
> function in Mathematica 5.2. Try the following;
>

> In[72]:=
> ArcTan[.5,$MachinePrecision]
> ArcTan[.5]
>
> Out[72]=
> 1.53947
>
> Out[73]=
> 0.463648
>

> The expression ArcTan[.5,$MachinePrecision] must (?) give an error but
> in really gives some strange output without any error messages... What
> do you think about this?
>

--
DrMaj...@bigfoot.com

Curtis F. Osterhoudt

unread,
Aug 18, 2009, 6:07:39 AM8/18/09
to
You've discovered the two-argument form of ArcTan; that is, it's returning
ArcTan[15.9546/0.5]. I suspect you want to feed a precision to Mathematica
in another way ...

Bob Hanlon

unread,
Aug 18, 2009, 6:07:50 AM8/18/09
to

$MachinePrecision is an integer (16 on my machine). Perhaps you meant to use ArcTan[0.5 + $MachineEpsilon]?


Bob Hanlon

---- Alexey <leh...@gmail.com> wrote:

=============

Bill Rowe

unread,
Aug 18, 2009, 6:08:11 AM8/18/09
to
On 8/17/09 at 8:06 AM, leh...@gmail.com (Alexey) wrote:

>Hello, I just have discovered some strange (buggy?) feature of
>ArcTan[] function in Mathematica 5.2. Try the following;

>In[72]:= ArcTan[.5,$MachinePrecision] ArcTan[.5]

>Out[72]= 1.53947

>Out[73]= 0.463648

>The expression ArcTan[.5,$MachinePrecision] must (?) give an error
>but in really gives some strange output without any error
>messages... What do you think about this?

It appears the result you are getting is entirely consistent
with the documented behavior of ArcTan which I am guessing you
have not looked at. Specifically, the documentation states
ArcTan[x,y] computes ArcTan[y/x] paying attention to the
quadrant (x,y) is in. Since $MachinePrecision returns a numeric
value there is no error generated when evaluating ArcTan[.5,
$MachinePrecision]. And since $MachinePrecision is a positive value

In[6]:= ArcTan[.5, $MachinePrecision] == ArcTan[$MachinePrecision/.5]

Out[6]= True

Nasser Abbasi

unread,
Aug 18, 2009, 6:08:22 AM8/18/09
to

"Alexey" <leh...@gmail.com> wrote in message
news:h6bh4m$6ov$1...@smc.vnet.net...


But it works as per help:

"ArcTan[z] gives the arc tangent tan^-1(z) of the complex number z.
ArcTan[x,y] gives the arc tangent of y/x, taking into account which quadrant
the point (x,y) is in. "

May be you meant to say:

In[33]:= N[ArcTan[0.5], $MachinePrecision]
Out[33]= 0.4636476090008061

In[34]:= ArcTan[0.5]
Out[34]= 0.4636476090008061


--Nasser


pfalloon

unread,
Aug 18, 2009, 6:08:01 AM8/18/09
to

You should check the documentation for the ArcTan function: there is a
form of this function which takes two inputs, so all you have done is
invoked that:

In[29]:= {x,y} = {0.5, $MachinePrecision};
ArcTan[x,y]

Out[30]= 1.53947

There is nothing buggy going on there, but clearly it's not what you
meant to do.

I'm not sure *what* you meant to do: if you were trying to get the
output to MachinePrecision, the above is not the way to do this (not
sure where you got the idea of adding a second argument: you need to
use the function N). But it is unnecessary in this case because the
argument 0.5 is already at machine precision. The following would be a
sensible input:

In[31]:= N[ArcTan[1/2]]

Out[31]= 0.463648

Note that this returns machine-precision output:

In[32]:= Precision[%]

Out[32]= MachinePrecision


Cheers,
Peter.

Adriano Pascoletti

unread,
Aug 18, 2009, 6:06:53 AM8/18/09
to
Alexey,

ArcTan[x,y] gives the arc tangent y/x taking into account which quadrant the
point (x,y) is in

In[1]:= $MachinePrecision
Out[1]= 15.9546


In[4]:= ArcTan[0.5, $MachinePrecision]
Out[4]= 1.5394676360951292


In[5]:= ArcTan[$MachinePrecision/0.5]
Out[5]= 1.539467636095129


Adriano Pascoletti


2009/8/17 Alexey <leh...@gmail.com>

David W. Cantrell

unread,
Aug 18, 2009, 6:05:37 AM8/18/09
to
Alexey <leh...@gmail.com> wrote:
> Hello,
> I just have discovered some strange (buggy?) feature of ArcTan[]
> function in Mathematica 5.2. Try the following;
>
> In[72]:=
> ArcTan[.5,$MachinePrecision]
> ArcTan[.5]
>
> Out[72]=
> 1.53947
>
> Out[73]=
> 0.463648
>
> The expression ArcTan[.5,$MachinePrecision] must (?) give an error

No. Look at the documentation for ArcTan. There is a very useful version of
ArcTan which takes _two_ arguments. And of course $MachinePrecision merely
supplies a numerical value for the second argument.

> but
> in really gives some strange output without any error messages... What
> do you think about this?

There's nothing wrong.

David

Tony Harker

unread,
Aug 18, 2009, 6:09:28 AM8/18/09
to
Dear Alexey,

Why are you surprised by the output? ArcTan is doing exactly what it
should when called with two arguments:

In[1]:= ArcTan[.5, $MachinePrecision]
ArcTan[.5]
$MachinePrecision
$MachinePrecision/.5
ArcTan[%]

Out[1]= 1.53947

Out[2]= 0.463648

Out[3]= 15.9546

Out[4]= 31.9092

Out[5]= 1.53947

Tony Harker

]-> -----Original Message-----
]-> From: Alexey [mailto:leh...@gmail.com]
]-> Sent: 17 August 2009 13:07
]-> To: math...@smc.vnet.net
]-> Subject: Very strange behaviour of ArcTan[]
]->
]-> Hello,
]-> I just have discovered some strange (buggy?) feature of
]-> ArcTan[] function in Mathematica 5.2. Try the following;
]->
]-> In[72]:=
]-> ArcTan[.5,$MachinePrecision]
]-> ArcTan[.5]
]->
]-> Out[72]=
]-> 1.53947
]->
]-> Out[73]=
]-> 0.463648
]->
]-> The expression ArcTan[.5,$MachinePrecision] must (?) give
]-> an error but in really gives some strange output without
]-> any error messages... What do you think about this?
]->
]->


Szabolcs Horvát

unread,
Aug 18, 2009, 6:09:39 AM8/18/09
to

What are you trying to do? According to the docs, "ArcTan[x,y] gives
the arc tangent of y/x, taking into account which quadrant the point
(x,y) is in."

0 new messages