Hubble Law

Clear["Global`*"]

tA=SessionTime[];
c1=299792458

galaxylist=Import["/Users/crojas/Documents/Courses/Cosmology/1st\ 2021/Evaluations/Homework\ 1/GalaxyList.csv"];
galaxycopy=galaxylist;
galaxylist[[1]]
numline=Length[galaxylist]
vgc:=Table[galaxylist[[ii,7]]+220 N[Cos[(galaxylist[[ii,5]] -90) °] Cos[galaxylist[[ii,6]] °]],{ii,2,numline}]

Here we make a new list without a header to hold the revised data. The Header is {Galaxy Name,Type (RC3),wt.,D,GLON,GLAT,Vgc}

vgc=Table[galaxylist[[ii,7]]+220 N[Cos[(galaxylist[[ii,5]] -90) °] Cos[galaxylist[[ii,6]] °]],{ii,2,numline}];
galaxylistR=Table[{galaxycopy[[ii,1]],galaxycopy[[ii,2]],galaxycopy[[ii,8]],galaxycopy[[ii,4]],galaxycopy[[ii,5]],galaxycopy[[ii,6]],vgc[[ii-1]]},{ii,2,numline}];
 datalist=Table[{galaxylistR[[ii,4]],vgc[[ii]]},{ii,1,numline-1}];
wtlist=Table[galaxylistR[[ii,3]],{ii,1,numline-1}];

The  Velocity Versus Distance Relationship

ListPlot[datalist,PlotRange->All,AxesLabel->{"d (Mpc)","v (km/s)"}]

The Special Relativistic Doppler Effect

z for optical observations is defined as a difference of wavelength to rest wavelength ratio.

νobsR:=(( (Sqrt[c-v]) νE)/(Sqrt[c+v]))
λobs:=(( (Sqrt[c+v]) )/(Sqrt[c-v])) λrest
zee:=FullSimplify[((λobs-λrest)/(λrest))]

For computation we put zee into a function to be able to put in v in km/s

c2=N[c1/1000]
zeeobs[v1_]:=zee/.{c->c2,v->v1};

Thus we build and plot a new database list this time using z instead of Doppler velocity.

datalistA:=Table[{galaxylistR[[ii,4]],zeeobs[vgc[[ii]]]},{ii,1,numline-1}]
dataplot=ListPlot[datalistA,PlotRange->All,AxesLabel->{"d (Mpc)","z"}]

Data Fits for the NED Data (2009) using z  versus Distance.

lmw3=LinearModelFit[datalistA,{d,(d^2)},d,Weights->wtlist^2,IncludeConstantBasis->False]

Computable expression for plotting

eqw3=Normal[lmw3]

Fit Coefficients

coeff3=lmw3["BestFitParameters"]

Coefficient Errors

coefe3=lmw3["ParameterErrors"]

Correlation Coefficient of Fit

ccoef3=(Sqrt[lmw3["RSquared"]])

Fit Coefficients in Standard Units (km/s / megaparsec)

coeff3 c2

Fit Errors  in Standard Units (km/s / megaparsec)

coefe3 c2

tplot3:=Plot[eqw3/.d->d1,{d1,0,7000},AxesLabel->{"d (Mpc)","z"}]
Show[{tplot3,dataplot}]