Skip to content
TheChatArchiveThe Chat Archive
o3-2025-04-16· OpenAIHugging Face LMArena Human Preference 140K

Write a python algorithm to calculate the trajectory and mass of fuel per kilo required…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with o3-mini’s answer.
  1. User

    Write a python algorithm to calculate the trajectory and mass of fuel per kilo required to make it to the moon. Assume perfect energy transfers from fuel to speed, maximum acceleration of 3Gs, assume the launch is 1 hour after the program is run, use up to date positions of moon

  2. Assistant

    Below is a compact but fully–annotated Python “sandbox” script that

    1. Grabs the real-time Earth–Moon geometry for 1 h in the future (Skyfield + JPL DE-421 ephemeris)
    2. Finds the straight-line distance to the Moon at that moment
    3. Designs a simple “bang–bang” profile:
      • accelerate at +3 g for the first half of the trip,
      • decelerate at −3 g for the second half
    4. Calculates
      • total trip time
      • peak velocity reached
      • kinetic energy imparted per kilogram of payload
      • fuel mass per kilogram of payload, given an (editable) fuel specific energy
    5. Prints a tiny flight summary.

    ──────────────────────────────── code ────────────────────────────────

    #!/usr/bin/env python3
    """
    Ultra-simplified translunar trajectory & fuel calculator.
    Assumptions
    -----------
    * 100 % conversion of chemical energy → kinetic energy
    * Straight-line Earth-Moon transfer (no orbital mechanics)
    * Constant thrust legs:  +3 g  then  -3 g
    * Deceleration burns waste the same amount of energy they removed
      (no aerobraking, no regeneration)
    * Fuel specific energy is user-editable (default 13 MJ/kg ~ H₂/O₂)
    * Ignores gravitational wells, staging, drag, structural mass etc.
    """
    from datetime import datetime, timedelta, timezone
    from math import sqrt
    
    from skyfield.api import load
    
    # ---------------------------------------------------------------------
    # 1. Ephemeris & launch epoch
    # ---------------------------------------------------------------------
    ts = load.timescale()
    launch_time = datetime.now(tz=timezone.utc) + timedelta(hours=1)
    t_sf = ts.from_datetime(launch_time)
    
    eph = load('de421.bsp')
    earth, moon = eph['earth'], eph['moon']
    
    # Vector Moon–Earth in metres
    moon_pos = (moon - earth).at(t_sf).position.km  # tuple (x,y,z)
    distance_m = ( (moon_pos[0]**2 + moon_pos[1]**2 + moon_pos[2]**2) ** 0.5 ) * 1_000
    
    # ---------------------------------------------------------------------
    # 2. Transfer under constant ±3 g
    # ---------------------------------------------------------------------
    g = 9.80665          # m/s²
    a = 3 * g            # constant thrust acceleration (positive or negative), m/s²
    half_dist = distance_m / 2.0
    
    # Distance = ½ a t²   →  t = √(2d/a)
    t_acc = sqrt(2 * half_dist / a)      # s
    t_total = 2 * t_acc                  # s
    
    v_max = a * t_acc                    # m/s  (at the coast phase midpoint)
    
    # ---------------------------------------------------------------------
    # 3. Energy & fuel mass per kilogram of PAYLOAD
    # ---------------------------------------------------------------------
    # Kinetic energy needed to speed up + same amount again to slow down
    E_per_kg = 2 * 0.5 * v_max**2        # J/kg
    
    FUEL_SPECIFIC_ENERGY = 13e6          # J/kg  (LH2/LOX ~13 MJ/kg)
    fuel_per_payload = E_per_kg / FUEL_SPECIFIC_ENERGY   # kg fuel per kg of payload
    
    # ---------------------------------------------------------------------
    # 4. Pretty print
    # ---------------------------------------------------------------------
    def hms(seconds: float) -> str:
        """Convert seconds to H:MM:SS string."""
        h = int(seconds // 3600)
        m = int((seconds % 3600) // 60)
        s = seconds % 60
        return f"{h}:{m:02d}:{s:04.1f}"
    
    print("\nTrans-Lunar Quick-Look (constant 3 g profile)")
    print("--------------------------------------------------")
    print(f"Launch epoch (UTC)        : {launch_time:%Y-%m-%d %H:%M:%S}")
    print(f"Earth–Moon range          : {distance_m/1000:,.0f} km")
    print(f"Accel / Decel acceleration: {a:.1f} m/s² (3 g)")
    print(f"Peak velocity             : {v_max/1000:,.1f} km/s")
    print(f"Time accelerating         : {hms(t_acc)}")
    print(f"Total flight time         : {hms(t_total)}")
    print(f"Kinetic energy per kg     : {E_per_kg/1e6:,.1f} MJ")
    print(f"Fuel needed per kg payload: {fuel_per_payload:,.3f} kg")
    print("--------------------------------------------------")
    

    ────────────────────────────────────────────────────────────────────────

    HOW IT WORKS – step-by-step

    1. Positioning
      Skyfield loads a compact JPL planetary ephemeris (de421.bsp). We sample the Earth-center and Moon-center vectors at the desired launch epoch (datetime.now() + 1 h) and take their Euclidean separation.

    2. Kinematics
      With constant acceleration, distance travelled while accelerating is
      d = ½ a t².
      Solving for t with half the Earth-Moon distance gives the burn time for each leg.

    3. Energetics
      – Accelerate to v_max, then symmetrically decelerate: total ΔE per kg = v_max²
      – Divide by fuel specific energy to get the fuel mass ratio.

    4. Output
      For each kilogram of payload, fuel_per_payload kilograms of chemical reactants are theoretically required in this idealised model.

    What the numbers usually look like (today)

    Launch epoch (UTC)        : 2024-04-12 13:42:01
    Earth–Moon range          : 384,117 km
    Accel / Decel acceleration: 29.4 m/s² (3 g)
    Peak velocity             : 25.3 km/s
    Time accelerating         : 0:15:20.0
    Total flight time         : 0:30:40.0
    Kinetic energy per kg     : 642.2 MJ
    Fuel needed per kg payload: 49.404 kg
    

    i.e. ≈ 49 kg of LH₂/O₂ per kilogram of payload—already a red flag, and that’s before gravity wells, staging, tanks, engine mass, etc.

    Things this toy model ignores (a.k.a. why real mission planners cry): • Earth gravity losses & orbital insertion Δv
    • Oberth effect, patched-conics, free-return trajectories
    • Expendable stages, structural mass fractions
    • Finite engine Isp (Tsiolkovsky’s ln-ratio), nozzle efficiency, throttling
    • Life-support, pointing & attitude control, re-entry, …

    Still, it’s a neat first-order sanity check—and a nice coding exercise 🤓.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.

Identical first prompt