write a function that conputes the mass of Earth
- User
write a function that conputes the mass of Earth
Assistant
Here's a function that computes the mass of Earth using gravitational physics:
def compute_earth_mass(surface_gravity=9.81, earth_radius=6.371e6, G=6.674e-11): """ Compute Earth's mass using surface gravity and radius. Parameters: surface_gravity (float): Earth's surface gravity in m/s² (default: 9.81) earth_radius (float): Earth's radius in meters (default: 6.371e6) G (float): Gravitational constant in m³/(kg·s²) (default: 6.674e-11) Returns: float: Earth's mass in kilograms Formula: M = g * R² / G where g is surface gravity, R is Earth's radius, G is gravitational constant """ mass = (surface_gravity * earth_radius**2) / G return mass # Example usage earth_mass = compute_earth_mass() print(f"Earth's mass: {earth_mass:.2e} kg") print(f"Earth's mass: {earth_mass/1e24:.2f} × 10²⁴ kg")
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.