# arctan(tan(pi/2)) =pi/2 ?

Sage evaluates tan(pi/2) to unsigned infinity which is true, but I want the above expression to work. Any way?

When I apply arctan(tan(pi/2)) it gives error. Shouldn't it return pi/2.

edit retag close merge delete

Sort by ยป oldest newest most voted

This is a basic calculus question, really. It would not make sense for arctan(tan(pi/2)) to return pi/2 because tan(pi/2) is not defined. Sage returns Infinity because the limit of tan(x) as x -> pi/2 from the left is +Infinity and from the right is -Infinity. However, the limit of arctan(y) as y -> +Infinity is pi/2 but as y -> -Infinity is -pi/2. So you have to ask Sage for a limit:

sage: x = var('x')
sage: assume(x > 0 and x < pi/2)
sage: f = arctan(tan(x))
sage: f.limit(x=pi/2, dir='left')
1/2*pi

sage: forget()
sage: assume( pi/2 < x and x < pi )
sage: f.limit(x=pi/2, dir='right')
-1/2*pi


See the documentation for limit for more info and a lot of good examples.

more

It could equally well return -pi/2:

sage: arctan(+Infinity)
1/2*pi
sage: arctan(-Infinity)
-1/2*pi


The limit as x -> pi/2 is undefined, because the limits from above and below are not equal:

sage: limit(arctan(tan(x)),x=pi/2)
und
sage: limit(arctan(tan(x)),x=pi/2,dir='+')
-1/2*pi
sage: limit(arctan(tan(x)),x=pi/2,dir='-')
1/2*pi

more