title: NameError: name 'cos' is not defined, sageMath9.4
body: <p>I am writing a Python module using <strong>SageMath9.4</strong>. Basically, I want to import this module into <strong>Jupyterlab</strong> Notebooks (running a SageMath 9.4 kernel) to do calculations etc.</p>
  <p>Here is the start of it:</p>
  <pre><code>class Coxeter_System:
  '''This class defines the standard root system associated to an abstract Coxeter group.'''
  
  def __init__(self, coxeter_matrix):
      '''Sets up a Coxeter system and root system. At this stage, limited to up to rank 7. 
      '''
      def set_up_coefficient_space(coxeter_matrix):
          '''Sets up a polynomial ring a Free module over a polynomial ring quotiented by the minimal polynomials of the 
          non-rational cos(pi/m_ij) values. 
          
          This is so roots can be compared using an abstract free module rather than over reals'''
          
          A = coxeter_matrix
          k = len(A.rows())
  
          # Get the cos(pi/m_ij) which are irrational
          non_rational_angles = [x for x in [cos(pi/x) for x in set(A[i,j] for i in range(0,k) for j in range(0,k))] if x not in QQ]
  </code></pre>
  <p>However, when I open another Jupyterlab session, import the Python module and try to create an instance of the object &quot;Coxeter_System&quot;, I get the following error (I have tried to do <code>from math import cos</code> both from the notebook where I want to import the module to, and in the module itself, but I still get the same error.</p>
  <p>Any help would be greatly appreciated!):</p>
  <pre><code>NameError                                 Traceback (most recent call last)
  &lt;ipython-input-6-6b542b6cb042&gt; in &lt;module&gt;
  ----&gt; 1 W = c.Coxeter_System(Matrix([[Integer(1),Integer(3),Integer(4)],[Integer(3),Integer(1),Integer(3)],[Integer(4),Integer(3),Integer(1)]]))
  
  ~/coxeter_groups.py in __init__(self, coxeter_matrix)
       60             return matrix(R,k,B)
       61 
  ---&gt; 62         R = set_up_coefficient_space(coxeter_matrix)
       63         A = coxeter_matrix
       64         k = len(A.rows())
  
  ~/coxeter_groups.py in set_up_coefficient_space(coxeter_matrix)
       17 
       18             # Get the cos(pi/m_ij) which are irrational
  ---&gt; 19             non_rational_angles = [x for x in [cos(pi/x) for x in set(A[i,j] for i in range(0,k) for j in range(0,k))] if x not in QQ]
       20 
       21             # sort the irrational values of cos(pi/m_ij) in ascending order
  
  ~/coxeter_groups.py in &lt;listcomp&gt;(.0)
       17 
       18             # Get the cos(pi/m_ij) which are irrational
  ---&gt; 19             non_rational_angles = [x for x in [cos(pi/x) for x in set(A[i,j] for i in range(0,k) for j in range(0,k))] if x not in QQ]
       20 
       21             # sort the irrational values of cos(pi/m_ij) in ascending order
  
  NameError: name 'cos' is not defined
  </code></pre>