Exercises lecture 1

Exercise 1 :
  define a function f[x] that gives the integral of the Legendre polynomial with n = 3 if x > 0 and x if x < 0; evaluate f[1], f[-1], f[0]

Exercise 2 :
 Use PrimeQ (and Table or Do) to test whether integers from 1 to N are prime or not

Exercise 3 :
 define a function that plots Gaussian distributions with arbitrary mean and variance; produse a plot with Show[] with several of these Gaussians

Exercise 4:
Generate a Hubble diagram: a plot of N=100 apparent magnitudes m versus redshift (up to z=2) of sources with absolute magnitude M=- 19.5 in a LCDM cosmological model with Gaussian magnitude scatter of 0.15 (use random number generators to create a scatter over the expected magnitude); overplot the theoretical behavior. You will need these formulas:

Clear[m,d];
aM=-19.5;m[z_,om0_]:=aM+25+5*Log10[d[z,om0]];
hub0=1/3000;
d[z_,om0_]:=NIntegrate[1/(hub0*Sqrt[om0*(1+zx)^3+1-om0]), {zx ,0 , z} ];