title: Simple numerical computation with python
body: <p>We are coding with python in my numerical analysis class and I am quite new to it, so I am not very sure I did it right and would appreciate your help. With python I need to compute:</p>
  
  <p>i) 0.01^2 and enter the answer rounded to 5 significant figures</p>
  
  <p>ii) f(0.000122) where f(x) = cosh(x) + cos(x) - 2, and round your answer to 18 decimal places.</p>
  
  <p>iii)Calculate the absolute error | f(x) - p_4(x) | at the point 0.981 if p_4(x) is the 4th-degree Taylor polynomial approximating f(x) = exp( pi*x ) with x_0 = 0</p>
  
  <p>What I did:</p>
  
  <p>i) My code would simply be</p>
  
  <pre class="lang-py prettyprint-override"><code>x=0.001**2:
      print(x)
  </code></pre>
  
  <p>Here I get 0.0001 but how should I round this now to 5 figures?</p>
  
  <p>ii) This time I had:</p>
  
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  x = 0.000122
  y = np.cosh(x) + np.cos(x) - 2
  print(round(y, 18))
  </code></pre>
  
  <p>But the solution gives me 0.0 and this seems wrong because... again it says round it to 18 decimal places.</p>
  
  <p>iii) Here I have just started with the taylor series:</p>
  
  <pre class="lang-py prettyprint-override"><code>import math
  x = math.pi*0.981
  p4 = x**0/math.factorial(0) + x**1/math.factorial(1) + x**2/math.factorial(2) + x**3/math.factorial(3) + x**4/math.factorial(4)
  print(p4)
  </code></pre>
  
  <p>Is this ok? Where do I use that $x_0=0$? I am always unsure, when I don't use every hint. My next step then would be:</p>
  
  <pre class="lang-py prettyprint-override"><code>error=abs(math.e**(math.pi*0.981)-p4)
  </code></pre>
  
  <p>Is this ok?</p>