2. Read the introduction of ”C++ for Scientific Computing ”, write, compile and run your own ”Hello World” code.
3. Read sections 2 to 8. Suggestion: run and modify the example codes.
(a) Give one reason to use C++ over Matlab.
(b) What are the pros and cons of using the double type to represent real numbers ?
(c) How would you decide to use int versus long ?
(d) What does the & operators does ? What about the * ?
(e) How would you declare a 3×4×5 array of real numbers, assuming that we want double precision ? How would you do it if at the time of compilation the array size N ×M ×L was not known ?
(f) If A is an array of double of size N, how do you access its first and last element ?
4. (a) Imagine you want to implement a function Legendre(double x, int n) which return the value of the nth Legendre Polynomial evaluated at x for 0 < n < 5. Which control structure would you use ? why ?
(b) Implement the Legendre(double x, int n) function. Your function should return an error message if n 6 or n < 0.
(c) Implement a function sampledLegendre(double a, double b, int N, int n) which return the vector of size N containing the values of the nth Legendre Polynomial at the uniformly distributed points x0 = a,...,xN−1 = b.
(d) How can you verify your code ?
(e) If we call AnN the output of sampledLegendre(-1,1, int N, int n), what is the limit as N → ∞ of the scalar product ? (You might wanna use what you just implemented to get some intuition...)