# HG changeset patch
# User Burcin Erocal <burcin@erocal.org>
# Date 1328629949 3600
# Node ID 515e51ea641eb7727753887b6cc35885b5441fd5
# Parent 72fbabe2d206dee8c6d87a7382b92e3856e61888
trac 4498: keep precision in numeric evaluation of symbolic arg
diff git a/sage/functions/other.py b/sage/functions/other.py
a

b


1344  1344  sage: arg(0) 
1345  1345  0 
1346  1346  sage: latex(arg(x)) 
1347   \text{arg}\left(x\right) 
 1347  {\rm arg}\left(x\right) 
1348  1348  sage: maxima(arg(x)) 
1349  1349  atan2(0,x) 
1350  1350  sage: maxima(arg(2+i)) 
… 
… 

1409  1409  # or x involves an expression such as sqrt(2) 
1410  1410  return None 
1411  1411  
1412   def _evalf_(self, x, parent=None): 
 1412  def _evalf_(self, x, parent_d=None): 
1413  1413  """ 
1414  1414  EXAMPLES:: 
1415  1415  
… 
… 

1417  1417  0.000000000000000 
1418  1418  sage: arg(3.0) 
1419  1419  0.000000000000000 
 1420  sage: arg(3.00000000000000000000000000) 
 1421  0.00000000000000000000000000 
 1422  sage: arg(3.00000000000000000000000000).prec() 
 1423  90 
 1424  sage: arg(ComplexIntervalField(90)(3)).prec() 
 1425  90 
 1426  sage: arg(ComplexIntervalField(90)(3)).parent() 
 1427  Real Interval Field with 90 bits of precision 
 1428  sage: arg(3.0r) 
 1429  0.000000000000000 
 1430  sage: arg(RDF(3)) 
 1431  0.0 
 1432  sage: arg(RDF(3)).parent() 
 1433  Real Double Field 
1420  1434  sage: arg(2.5) 
1421  1435  3.14159265358979 
1422  1436  sage: arg(2.0+3*i) 
… 
… 

1425  1439  try: 
1426  1440  return x.arg() 
1427  1441  except AttributeError: 
1428   from sage.rings.complex_field import CC 
1429   x = CC(x) 
1430   return x.arg() 
 1442  pass 
 1443  # try to find a parent that support .arg() 
 1444  if parent_d is None: 
 1445  parent_d = parent(x) 
 1446  try: 
 1447  parent_d = parent_d.complex_field() 
 1448  except AttributeError: 
 1449  from sage.rings.complex_field import ComplexField 
 1450  try: 
 1451  parent_d = ComplexField(x.prec()) 
 1452  except AttributeError: 
 1453  parent_d = ComplexField() 
 1454  
 1455  return parent_d(x).arg() 
1431  1456  
1432  1457  arg=Function_arg() 
1433  1458  