Help with Python computation to calculate age of universe

In summary, the conversation is about using python to calculate the age of the universe by finding the distance modulus for a set of galaxies, converting to parsecs, and then using Hubble's constant. The person is getting values that are off by 10 magnitudes and suspects it is due to unit conversion. They share their code for calculating Hubble's constant and ask about the meaning of AVG_DPC_V and the formula used to calculate it. They also mention that the Hubble constant is off by a factor of 10, which affects the age of the universe. They then realize that the error may be due to a mistake in their formula and ask for confirmation.
  • #1
Pavkazz
2
0

Homework Statement


I'm using python to calculate the age of the universe, by working out the distmodulus for a set of galaxys (using the V and I bands) then working out the distance in parsecs and then hubbles constant etc... I keep getting values that are 10s of magnitudes out which I assume has something to do with my unit conversion.

Homework Equations


vrec = H0*Dgal.
5 log dpc − 5 + AV = µ + AV

The Attempt at a Solution


Below is my code to work out hubbles constant. My Distance mod is accurate [/B]
 

Attachments

  • Screen Shot 2016-01-29 at 14.52.30.png
    Screen Shot 2016-01-29 at 14.52.30.png
    102.8 KB · Views: 482
Technology news on Phys.org
  • #2
What is AVG_DPC_V and what does the formula calculating it mean? What is f?
The Hubble constant is a factor 10 too large, that error propagates to the age of the universe.
 
  • #3
By the way, if you enclose your code in "code" tags, we can see your code with the appropriate formatting and even run it if we like. This makes it easier for people to understand code related questions. Below is an example.

Code:
import numpy as np
x = 0.5
y = np.sin(x)
print "The sine of %f is %f"%(x,y)
 
  • #4
mfb said:
What is AVG_DPC_V and what does the formula calculating it mean? What is f?
The Hubble constant is a factor 10 too large, that error propagates to the age of the universe.
Average distance in the V band and the formula calculating is (5 log dpc − 5 + AV = µ + AV) which is dpc = 10^u/5 + 1. I think I may have solved the issue? Is it simply the bracket in the equation above where I am calculating (10^u/5) +1 not 10^(u/5 + 1)?
 
  • #5
The +1 should be in the exponent, right.
 

Related to Help with Python computation to calculate age of universe

1. How do you calculate the age of the universe using Python?

To calculate the age of the universe using Python, you can use the following formula: age = 1/H0 * integral from 0 to z of dz / (1+z) * 1/sqrt(Ωm(1+z)^3 + Ωr(1+z)^4 + ΩΛ), where H0 is the Hubble constant, z is the redshift, and Ωm, Ωr, and ΩΛ are the density parameters for matter, radiation, and dark energy, respectively. You can input values for these parameters and the redshift to get an estimated age of the universe in years.

2. Is there a built-in function in Python for calculating the age of the universe?

No, there is no built-in function in Python specifically for calculating the age of the universe. However, there are various libraries and packages available that can be used to perform the necessary calculations, such as the Astropy cosmology module.

3. How accurate is the age of the universe calculated using Python?

The accuracy of the age of the universe calculated using Python depends on the accuracy of the input parameters used in the calculation. The more accurate and precise the values for H0, Ωm, Ωr, ΩΛ, and the redshift are, the more accurate the calculated age will be. However, it should be noted that the age of the universe is still a topic of ongoing research and there is no definitive answer, so any calculated age should be considered an estimate.

4. Can Python be used to calculate the age of the universe in different units?

Yes, Python can be used to calculate the age of the universe in different units. The output of the calculation will depend on the units used for the input parameters, so you can choose the units that are most convenient for you. For example, you can calculate the age in seconds, years, or even gigayears.

5. Are there any limitations to using Python for calculating the age of the universe?

One limitation of using Python for calculating the age of the universe is that it relies on the accuracy of the input parameters and the underlying assumptions made in the calculation. It is also important to note that the age of the universe is constantly being revised and updated as new data and theories are discovered, so any calculated age may become outdated over time.

Similar threads

Replies
21
Views
2K
Replies
1
Views
1K
Replies
3
Views
1K
Replies
3
Views
1K
  • Cosmology
Replies
14
Views
2K
  • Programming and Computer Science
Replies
29
Views
3K
  • Astronomy and Astrophysics
Replies
8
Views
2K
  • Programming and Computer Science
Replies
2
Views
16K
  • Cosmology
Replies
4
Views
1K
Back
Top