File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,13 @@ def asin(x, context=None):
198198
199199 with localcontext (context ) as ctx :
200200 ctx .prec += 2
201- r = atan (x / (1 - x * x ).sqrt ())
201+ pi = Decimal (1 ).atan () * 4
202+ if x == 1 :
203+ r = pi / 2 # pi * 1/2 radians
204+ elif x == - 1 :
205+ r = pi * 3 / 2 # pi * 3/2 radians
206+ else :
207+ r = atan (x / (1 - x * x ).sqrt ())
202208 return r / 1
203209
204210
@@ -218,10 +224,15 @@ def acos(x, context=None):
218224
219225 with localcontext (context ) as ctx :
220226 ctx .prec += 2
221- r = atan ((1 - x * x ).sqrt () / x )
227+ if x == 1 :
228+ r = Decimal (0 ). # 0 radians
229+ elif x == - 1 :
230+ r = Decimal (1 ).atan () * 4 # pi radians
231+ else :
232+ r = atan ((1 - x * x ).sqrt () / x )
222233 if r < 0 :
223234 r += 4 * atan (1 )
224- return r
235+ return r / 1
225236
226237
227238for name in __all__ :
You can’t perform that action at this time.
0 commit comments