Root finding & Integration

←Previous

Homework assignment

The following homework assignment will be due on Monday, 6.11..

Use the skeleton code in Integrator.py, Functions.py and Error.py to implement the Newton-Cotes, Trapezoidal and Simpson rules discussed in the lecture and the Bessel functions Jn(x) in a series and an integral representation.

The assignment consists of the following parts:

  1. Implement the integration methods from the lecture with a fixed number of panels in integrate_Nsteps(self,x0,x1,N). To this end, fill in the following methods (in Integrator.py):

    where in all cases $x_i = a+i\Delta x$ and $\Delta x = (b-a)/N$.

    For testing purposes you may take as "kernel" the function $x^n$, implemented as xtoN in the Functions.py file.

  2. Use these methods to implement an integration, which runs until a predefined accuracy goal has been reached, in the function
    integrate_Accuracy(self,x0,x1,Ninit,accuracy) in Integrator.py.

    Start with a fixed number of panels, N and store the result for this number of panels $I_f^{(a,b)}(N)$ and for twice the number of panels, $I_f^{(a,b)}(2N)$. Keep doubling the number of panels $N$, $N\to 2N$, until the error function (imported from Error.py) applied to two consecutive results yields a result smaller than the accuracy goal.

    Hint: You may want to reuse the method integrate_Nsteps(self,x0,x1,N).

  3. Implement a numerical treatment of the Bessel functions $J_n(x)$ in two ways:

    Hint: These Bessel functions and other special functions are provided in scipy. You may use these implementations to check your results, but, of course, you cannot use them as part of the homework solution.

    Hint: The Gamma-function has been added, again by a series and an integral representation, to see how this should work for the case of the Bessel function. Note, however, that the convergence behaviour of the Γ-function is bad.





Frank Krauss and Daniel Maitre
Last modified: Tue Oct 3 14:43:58 BST 2017