Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In

CoCalc News
RSS Feed
JSON Feed

Recent news about CoCalc. You can also subscribe via RSS Feed RSS Feed or JSON Feed JSON Feed.
Filter

Starting today, our default software environment for new projects is based on Ubuntu 24.04. You can still select the previous default, Ubuntu 22.04 (available until June 2025), when creating new projects. While we plan to support Ubuntu 22.04 for a while longer, our main focus going forward will be on Ubuntu 24.04.

Existing projects are unaffected. If you want to switch, you can do this any time via Project Settings → Project Control → Software Environment.

To see what’s included, check out our software inventory.

Programming Languages and Features

  • Python: There is now a new "CoCalc Python" environment, featuring a curated set of popular packages. This replaces the previously called "system-wide" environment. Terminals now run inside this environment by default. The main benefit is, that this allows to manage Python packages without depending on system-wide packages, installed for system utilities. As before, you can also use the Anaconda-based environment via anaconda2025, and we continue to offer a Colab-compatible environment.

  • R: We now provide a broader selection of R packages, powered by r2u, making it easier and more convenient to get started.

  • SageMath: The latest version of SageMath is available in the new environment. For earlier SageMath releases, please switch to the "Ubuntu 22.04" environment.

  • LaTeX: This is now running a full and up-to-date Texlive distribution. We plan to update its packages with each new software environment update.

This week, NVIDIA highlighted CoCalc as a key platform for teaching with its CUDA-Q academic materials. In their technical blog post, NVIDIA mentions how CoCalc can provide a seamless learning environment for the next wave of quantum computing specialists.

This might also be a good time to add that we were officially accepted as an NVIDIA Inception Program Member a while back!

Our Chief Sales Officer, Blaec Bejarano, has had the pleasure of meeting Monica Van Dieren, a Senior Technical Marketing Engineer at NVIDIA, at the Joint Mathematics Meeting in Seattle this past January. Their discussions continued at the NVIDIA GTC conference in San Jose in March, solidifying our shared vision for accessible and powerful quantum computing education.

NVIDIA's CUDA-Q Academic program is a comprehensive suite of Jupyter notebooks designed to bridge the gap between theoretical quantum mechanics and practical application. These resources are now readily available via CoCalc, allowing students and instructors to dive into complex topics like quantum machine learning and variational algorithms without the hassle of a complex setup.

The synergy between CoCalc's collaborative platform and NVIDIA's cutting-edge educational content creates an unparalleled learning experience. Students can work through CUDA-Q modules, leveraging CoCalc's powerful computational resources and real-time collaboration features. This integration is particularly highlighted in NVIDIA's post, which notes the ease of getting started on platforms like CoCalc.

For those eager to explore these resources, the CUDA-Q Academic GitHub repository is the perfect starting point: https://github.com/NVIDIA/cuda-q-academic/tree/main?tab=readme-ov-file

We are thrilled to be at the forefront of education, providing the tools necessary to train the quantum workforce of the future. The journey with NVIDIA is just beginning, and we look forward to empowering more learners around the globe.

sagemath
2025-04-09

The software environments "Ubuntu 22.04 (Default)" and "Ubuntu 24.04 (Testing)" now contain the most recent version of SageMath 10.6. You can select the software environment in Project Settings → Project Control → Software Environment. If you're already on the default Ubuntu 22.04 line, then you might have to restart your project to get the latest version.

Apart from that, don't forget to update the Sage Jupyter Kernel to run the latest version 😉

You can now use compute servers very easily with CoCalc's course management system. This video shows how to create a compute server associated to an assignment in a CoCalc course, then make private copies of that compute server available to all students in the class. You can easily set idle timeout, spend limits and a shutdown time for all student compute servers. You can also very easily control some or all servers in a class or install custom software on all servers.

This new functionality is the result of extensive discussions with many teachers who are already using CoCalc in the courses, and want to expand their classes to gives students real experience involving AI, deep learning and more using state of the art GPU's.

https://youtu.be/ikktaiw14Tw?si=_a6HxTRgDeN2NrVg

There are now four new compute server automatic shutdown and health check strategies: idle timeout, shutdown time, spending limit, and generic health check. Each can give you better insight into how your compute servers are used and save you substantial money. This video describes each in detail:

https://youtu.be/Kx_47fs_xcI?si=99Ex4yNQ14IVzkmD

Bridging Theory and Computation in Physics

Transforming Physics Understanding Through Computation

Physics—the study of matter, energy, and their interactions—has always been deeply mathematical. Today, computational methods have become essential tools for understanding complex physical phenomena that resist analytical solutions. CoCalc provides an ideal environment for learning physics through the powerful combination of theoretical understanding and computational exploration.

For information about available scientific computing tools and environments, see the CoCalc documentation.

Whether you're modeling planetary motion, analyzing quantum systems, or exploring electromagnetic fields, CoCalc's integrated tools help you visualize, simulate, and understand the physical world in ways that traditional methods alone cannot achieve.

Your Computational Physics Toolkit

Python for Physics: The Foundation

Python has become the lingua franca of computational physics, offering powerful libraries and intuitive syntax:

# Essential physics imports import numpy as np import matplotlib.pyplot as plt from scipy import integrate, optimize import sympy as sp # Welcome to computational physics! print("Welcome to Computational Physics with CoCalc!") # Physical constants (in SI units) c = 299792458 # Speed of light (m/s) h = 6.62607015e-34 # Planck constant (J⋅s) hbar = h / (2 * np.pi) # Reduced Planck constant k_B = 1.380649e-23 # Boltzmann constant (J/K) e = 1.602176634e-19 # Elementary charge (C) m_e = 9.1093837015e-31 # Electron mass (kg) m_p = 1.67262192369e-27 # Proton mass (kg) print(f"Speed of light: {c:.0e} m/s") print(f"Planck constant: {h:.3e} J⋅s") print(f"Electron mass: {m_e:.3e} kg")

Mechanics: Motion and Forces

Start your physics journey with classical mechanics:

# Classical mechanics: projectile motion def projectile_motion(): """ Simulate projectile motion with air resistance """ # Parameters g = 9.81 # Gravitational acceleration (m/s²) v0 = 50 # Initial velocity (m/s) angle = 45 # Launch angle (degrees) m = 1.0 # Mass (kg) b = 0.1 # Air resistance coefficient # Convert angle to radians theta = np.radians(angle) # Initial conditions vx0 = v0 * np.cos(theta) vy0 = v0 * np.sin(theta) # Differential equation: F = ma = -mg - bv def equations_of_motion(t, state): x, y, vx, vy = state # Air resistance force v_magnitude = np.sqrt(vx**2 + vy**2) if v_magnitude > 0: ax = -b * vx * v_magnitude / m ay = -g - b * vy * v_magnitude / m else: ax = 0 ay = -g return [vx, vy, ax, ay] # Solve the differential equation t_span = (0, 10) initial_state = [0, 0, vx0, vy0] # Event function to stop when projectile hits ground def hit_ground(t, state): return state[1] # y-coordinate hit_ground.terminal = True hit_ground.direction = -1 solution = integrate.solve_ivp( equations_of_motion, t_span, initial_state, events=hit_ground, dense_output=True, rtol=1e-8 ) # Extract trajectory t_flight = solution.t trajectory = solution.y # Plot trajectory plt.figure(figsize=(10, 6)) plt.plot(trajectory[0], trajectory[1], 'b-', linewidth=2, label='With air resistance') # Compare with no air resistance (analytical solution) t_no_air = np.linspace(0, t_flight[-1], 100) x_no_air = vx0 * t_no_air y_no_air = vy0 * t_no_air - 0.5 * g * t_no_air**2 plt.plot(x_no_air, y_no_air, 'r--', linewidth=2, label='No air resistance') plt.xlabel('Horizontal Distance (m)') plt.ylabel('Height (m)') plt.title(f'Projectile Motion (v₀={v0} m/s, θ={angle}°)') plt.legend() plt.grid(True, alpha=0.3) plt.show() # Calculate range range_with_air = trajectory[0][-1] range_no_air = v0**2 * np.sin(2*theta) / g print(f"Range with air resistance: {range_with_air:.1f} m") print(f"Range without air resistance: {range_no_air:.1f} m") print(f"Air resistance reduces range by: {(1 - range_with_air/range_no_air)*100:.1f}%") return t_flight, trajectory # Execute projectile motion simulation time, trajectory = projectile_motion()

Oscillations and Waves

Explore periodic motion and wave phenomena:

# Simple harmonic motion and damped oscillations def harmonic_oscillator(): """ Study simple harmonic motion and damping effects """ # Parameters omega_0 = 2.0 # Natural frequency (rad/s) gamma = 0.1 # Damping coefficient F0 = 1.0 # Driving force amplitude omega_d = 1.8 # Driving frequency # Equation of motion: m*x'' + gamma*x' + k*x = F*cos(omega_d*t) # Using omega_0^2 = k/m, we get: x'' + gamma*x' + omega_0^2*x = (F0/m)*cos(omega_d*t) def oscillator_equation(t, state): x, v = state # Driving force driving_force = F0 * np.cos(omega_d * t) # Acceleration a = -2*gamma*v - omega_0**2*x + driving_force return [v, a] # Time array t = np.linspace(0, 20, 1000) # Solve for different initial conditions solutions = {} initial_conditions = [ (1.0, 0.0, "x₀=1, v₀=0"), (0.0, 2.0, "x₀=0, v₀=2"), (0.5, 1.0, "x₀=0.5, v₀=1") ] plt.figure(figsize=(12, 8)) for i, (x0, v0, label) in enumerate(initial_conditions): solution = integrate.solve_ivp( oscillator_equation, (0, 20), [x0, v0], t_eval=t, rtol=1e-8 ) solutions[label] = solution plt.subplot(2, 2, i+1) plt.plot(solution.t, solution.y[0], 'b-', linewidth=1.5) plt.xlabel('Time (s)') plt.ylabel('Position (m)') plt.title(f'Damped Oscillator: {label}') plt.grid(True, alpha=0.3) # Phase space plot plt.subplot(2, 2, 4) for label, solution in solutions.items(): plt.plot(solution.y[0], solution.y[1], linewidth=1.5, label=label) plt.xlabel('Position (m)') plt.ylabel('Velocity (m/s)') plt.title('Phase Space') plt.legend() plt.grid(True, alpha=0.3) plt.tight_layout() plt.show() # Analyze frequency response frequencies = np.linspace(0.1, 4.0, 100) amplitude_response = [] for omega in frequencies: # Steady-state amplitude for driven oscillator amplitude = F0 / np.sqrt((omega_0**2 - omega**2)**2 + (2*gamma*omega)**2) amplitude_response.append(amplitude) plt.figure(figsize=(10, 6)) plt.plot(frequencies, amplitude_response, 'r-', linewidth=2) plt.axvline(omega_0, color='b', linestyle='--', alpha=0.7, label=f'ω₀ = {omega_0}') plt.xlabel('Driving Frequency (rad/s)') plt.ylabel('Steady-State Amplitude') plt.title('Frequency Response of Damped Harmonic Oscillator') plt.legend() plt.grid(True, alpha=0.3) plt.show() return solutions, amplitude_response # Execute oscillator analysis oscillator_solutions, frequency_response = harmonic_oscillator()

Electromagnetism: Fields and Forces

Explore electric and magnetic phenomena:

# Electromagnetic field visualization def electromagnetic_fields(): """ Visualize electric and magnetic fields """ # Electric field of point charges def electric_field_point_charges(): """Visualize electric field of multiple point charges""" # Define point charges: (x, y, charge) charges = [ (2, 2, 1.0), # Positive charge (-2, -2, -1.0), # Negative charge (0, 3, 0.5), # Smaller positive charge ] # Create grid x = np.linspace(-4, 4, 20) y = np.linspace(-4, 4, 20) X, Y = np.meshgrid(x, y) # Calculate electric field Ex = np.zeros_like(X) Ey = np.zeros_like(Y) V = np.zeros_like(X) # Electric potential k = 8.99e9 # Coulomb constant (N⋅m²/C²) for charge_x, charge_y, q in charges: # Distance from each grid point to the charge dx = X - charge_x dy = Y - charge_y r = np.sqrt(dx**2 + dy**2) # Avoid division by zero r = np.where(r < 0.1, 0.1, r) # Electric field components Ex += k * q * dx / r**3 Ey += k * q * dy / r**3 # Electric potential V += k * q / r # Plot electric field and equipotential lines plt.figure(figsize=(12, 5)) # Electric field vectors plt.subplot(1, 2, 1) plt.quiver(X, Y, Ex, Ey, np.sqrt(Ex**2 + Ey**2), cmap='viridis', alpha=0.7) # Mark charge locations for charge_x, charge_y, q in charges: color = 'red' if q > 0 else 'blue' size = abs(q) * 100 plt.scatter(charge_x, charge_y, c=color, s=size, edgecolors='black') plt.xlabel('x (m)') plt.ylabel('y (m)') plt.title('Electric Field') plt.axis('equal') plt.colorbar(label='Field Magnitude') # Equipotential lines plt.subplot(1, 2, 2) contour = plt.contour(X, Y, V, levels=20, colors='blue', alpha=0.6) plt.clabel(contour, inline=True, fontsize=8) # Mark charge locations for charge_x, charge_y, q in charges: color = 'red' if q > 0 else 'blue' size = abs(q) * 100 plt.scatter(charge_x, charge_y, c=color, s=size, edgecolors='black') plt.xlabel('x (m)') plt.ylabel('y (m)') plt.title('Electric Potential') plt.axis('equal') plt.tight_layout() plt.show() return X, Y, Ex, Ey, V # Magnetic field of current loop def magnetic_field_current_loop(): """Magnetic field of a circular current loop""" # Parameters I = 1.0 # Current (A) R = 1.0 # Loop radius (m) mu_0 = 4*np.pi*1e-7 # Permeability of free space # Calculate field along axis z = np.linspace(-3, 3, 100) Bz = mu_0 * I * R**2 / (2 * (R**2 + z**2)**(3/2)) plt.figure(figsize=(10, 6)) plt.subplot(1, 2, 1) plt.plot(z, Bz*1e6, 'b-', linewidth=2) plt.xlabel('Distance along axis (m)') plt.ylabel('Magnetic Field (μT)') plt.title(f'Magnetic Field of Current Loop (I={I}A, R={R}m)') plt.grid(True, alpha=0.3) # Field lines visualization (simplified) plt.subplot(1, 2, 2) theta = np.linspace(0, 2*np.pi, 100) loop_x = R * np.cos(theta) loop_y = R * np.sin(theta) # Draw current loop plt.plot(loop_x, loop_y, 'r-', linewidth=3, label='Current Loop') # Simplified field line representation r_field = np.linspace(0.2, 3, 10) for r in r_field: # Approximate field lines phi = np.linspace(0, 2*np.pi, 50) field_x = r * np.cos(phi) field_y = 0.5 * r * np.sin(phi) plt.plot(field_x, field_y, 'b-', alpha=0.5, linewidth=1) plt.plot(field_x, -field_y, 'b-', alpha=0.5, linewidth=1) plt.xlabel('x (m)') plt.ylabel('y (m)') plt.title('Magnetic Field Lines') plt.axis('equal') plt.legend() plt.tight_layout() plt.show() return z, Bz # Execute electromagnetic field calculations electric_results = electric_field_point_charges() magnetic_results = magnetic_field_current_loop() return electric_results, magnetic_results # Execute electromagnetic field analysis em_results = electromagnetic_fields()

Thermodynamics and Statistical Mechanics

Explore thermal phenomena and statistical behavior:

# Thermodynamics and kinetic theory def thermal_physics(): """ Explore thermodynamics and statistical mechanics """ # Ideal gas law and kinetic theory def kinetic_theory_simulation(): """Simulate kinetic theory of gases""" # Parameters N = 1000 # Number of particles T = 300 # Temperature (K) m = 4.65e-26 # Mass of N2 molecule (kg) # Maxwell-Boltzmann distribution def maxwell_boltzmann(v, T, m): """Maxwell-Boltzmann speed distribution""" k_B = 1.38e-23 factor = 4 * np.pi * (m / (2 * np.pi * k_B * T))**(3/2) return factor * v**2 * np.exp(-m * v**2 / (2 * k_B * T)) # Generate random velocities according to Maxwell-Boltzmann # (Simplified: using normal distribution for each component) sigma = np.sqrt(k_B * T / m) # Standard deviation for each component vx = np.random.normal(0, sigma, N) vy = np.random.normal(0, sigma, N) vz = np.random.normal(0, sigma, N) # Calculate speeds speeds = np.sqrt(vx**2 + vy**2 + vz**2) # Plot speed distribution plt.figure(figsize=(12, 8)) plt.subplot(2, 2, 1) plt.hist(speeds, bins=50, density=True, alpha=0.7, label='Simulation') # Theoretical Maxwell-Boltzmann distribution v_theory = np.linspace(0, np.max(speeds), 200) mb_theory = maxwell_boltzmann(v_theory, T, m) plt.plot(v_theory, mb_theory, 'r-', linewidth=2, label='Theory') plt.xlabel('Speed (m/s)') plt.ylabel('Probability Density') plt.title(f'Maxwell-Boltzmann Distribution (T={T}K)') plt.legend() plt.grid(True, alpha=0.3) # Calculate characteristic speeds v_avg = np.mean(speeds) v_rms = np.sqrt(np.mean(speeds**2)) v_mp = np.sqrt(2 * k_B * T / m) # Most probable speed plt.axvline(v_avg, color='blue', linestyle='--', label=f'Average: {v_avg:.0f} m/s') plt.axvline(v_rms, color='green', linestyle='--', label=f'RMS: {v_rms:.0f} m/s') plt.axvline(v_mp, color='red', linestyle='--', label=f'Most probable: {v_mp:.0f} m/s') plt.legend() # Energy distribution plt.subplot(2, 2, 2) kinetic_energies = 0.5 * m * speeds**2 plt.hist(kinetic_energies / k_B, bins=50, density=True, alpha=0.7) plt.xlabel('Kinetic Energy / k_B (K)') plt.ylabel('Probability Density') plt.title('Kinetic Energy Distribution') plt.grid(True, alpha=0.3) # Temperature dependence plt.subplot(2, 2, 3) temperatures = [200, 300, 400, 500] v_range = np.linspace(0, 1500, 200) for T_temp in temperatures: mb_dist = maxwell_boltzmann(v_range, T_temp, m) plt.plot(v_range, mb_dist, linewidth=2, label=f'T = {T_temp}K') plt.xlabel('Speed (m/s)') plt.ylabel('Probability Density') plt.title('Temperature Dependence') plt.legend() plt.grid(True, alpha=0.3) # Pressure calculation from kinetic theory plt.subplot(2, 2, 4) volumes = np.linspace(0.01, 0.1, 100) # m³ n_moles = 1.0 # mol R = 8.314 # J/(mol⋅K) # Ideal gas law: PV = nRT pressures_ideal = n_moles * R * T / volumes plt.plot(volumes*1000, pressures_ideal/1000, 'b-', linewidth=2, label='Ideal Gas Law') plt.xlabel('Volume (L)') plt.ylabel('Pressure (kPa)') plt.title(f'P-V Diagram (T={T}K)') plt.grid(True, alpha=0.3) plt.legend() plt.tight_layout() plt.show() print(f"Theoretical values at T = {T}K:") print(f"Average speed: {np.sqrt(8*k_B*T/(np.pi*m)):.0f} m/s") print(f"RMS speed: {np.sqrt(3*k_B*T/m):.0f} m/s") print(f"Most probable speed: {np.sqrt(2*k_B*T/m):.0f} m/s") return speeds, kinetic_energies # Heat transfer def heat_transfer_simulation(): """Simulate heat conduction""" # One-dimensional heat equation: ∂T/∂t = α ∂²T/∂x² # where α is thermal diffusivity # Parameters L = 1.0 # Length (m) alpha = 1e-4 # Thermal diffusivity (m²/s) dx = 0.01 # Spatial step dt = 0.1 # Time step t_max = 3600 # Maximum time (s) # Grid x = np.arange(0, L + dx, dx) nx = len(x) # Check stability condition stability = alpha * dt / dx**2 print(f"Stability parameter: {stability:.3f} (should be ≤ 0.5)") # Initial condition: hot at one end, cold at the other T = np.zeros(nx) T[0] = 100 # Hot end (°C) T[-1] = 0 # Cold end (°C) # Time stepping times = np.arange(0, t_max + dt, dt) T_history = [] for t in times[::int(len(times)/10)]: # Store every 10th time step T_history.append(T.copy()) # Update temperature using finite difference T_new = T.copy() for i in range(1, nx-1): T_new[i] = T[i] + alpha * dt / dx**2 * (T[i+1] - 2*T[i] + T[i-1]) T = T_new # Plot temperature evolution plt.figure(figsize=(10, 6)) plt.subplot(1, 2, 1) for i, T_snapshot in enumerate(T_history): time_label = f't = {i * t_max / 10 / 60:.0f} min' plt.plot(x, T_snapshot, linewidth=2, label=time_label) plt.xlabel('Position (m)') plt.ylabel('Temperature (°C)') plt.title('Heat Conduction Over Time') plt.legend() plt.grid(True, alpha=0.3) # Steady-state solution (linear) plt.subplot(1, 2, 2) T_steady = 100 * (1 - x / L) # Linear temperature profile plt.plot(x, T_history[-1], 'b-', linewidth=2, label='Numerical solution') plt.plot(x, T_steady, 'r--', linewidth=2, label='Analytical steady-state') plt.xlabel('Position (m)') plt.ylabel('Temperature (°C)') plt.title('Final Temperature Profile') plt.legend() plt.grid(True, alpha=0.3) plt.tight_layout() plt.show() return x, T_history # Execute thermal physics simulations speeds, energies = kinetic_theory_simulation() x_heat, T_heat = heat_transfer_simulation() return speeds, energies, x_heat, T_heat # Execute thermal physics analysis thermal_results = thermal_physics()

Building Physics Intuition

Dimensional Analysis and Scaling

Physics understanding begins with dimensional analysis:

# Dimensional analysis tools def dimensional_analysis(): """ Explore dimensional analysis and scaling laws """ # Fundamental dimensions dimensions = { 'length': 'L', 'mass': 'M', 'time': 'T', 'electric_current': 'I', 'temperature': 'Θ', 'amount': 'N', 'luminous_intensity': 'J' } # Common physical quantities and their dimensions quantities = { 'velocity': 'L T⁻¹', 'acceleration': 'L T⁻²', 'force': 'M L T⁻²', 'energy': 'M L² T⁻²', 'power': 'M L² T⁻³', 'pressure': 'M L⁻¹ T⁻²', 'electric_field': 'M L T⁻³ I⁻¹', 'magnetic_field': 'M T⁻² I⁻¹' } print("DIMENSIONAL ANALYSIS EXAMPLES") print("="*40) # Example 1: Pendulum period print("Example 1: Simple Pendulum Period") print("Variables: length L, gravity g, mass m") print("Dimensions: [L] = L, [g] = L T⁻², [m] = M") print("Proposed form: T = L^a × g^b × m^c") print("Dimension equation: T = L^a × (L T⁻²)^b × M^c") print(" T = L^(a+b) × T^(-2b) × M^c") print("Matching dimensions:") print(" Time: 1 = -2b → b = -1/2") print(" Length: 0 = a + b → a = 1/2") print(" Mass: 0 = c → c = 0") print("Result: T ∝ √(L/g)") # Numerical verification L_values = np.array([0.5, 1.0, 1.5, 2.0]) # lengths in meters g = 9.81 T_predicted = 2 * np.pi * np.sqrt(L_values / g) plt.figure(figsize=(10, 6)) plt.subplot(1, 2, 1) plt.plot(L_values, T_predicted, 'bo-', linewidth=2, markersize=8) plt.xlabel('Length (m)') plt.ylabel('Period (s)') plt.title('Pendulum Period vs Length') plt.grid(True, alpha=0.3) # Example 2: Drag force scaling print("\nExample 2: Drag Force at High Speed") print("Variables: velocity v, density ρ, area A, coefficient C_d") print("Expected form: F_drag = ½ × C_d × ρ × A × v²") # Show velocity scaling velocities = np.linspace(10, 100, 20) rho = 1.225 # Air density (kg/m³) A = 2.0 # Cross-sectional area (m²) C_d = 0.3 # Drag coefficient F_drag = 0.5 * C_d * rho * A * velocities**2 plt.subplot(1, 2, 2) plt.plot(velocities, F_drag, 'r-', linewidth=2) plt.xlabel('Velocity (m/s)') plt.ylabel('Drag Force (N)') plt.title('Drag Force vs Velocity (∝ v²)') plt.grid(True, alpha=0.3) plt.tight_layout() plt.show() return quantities, T_predicted, F_drag # Execute dimensional analysis dim_analysis = dimensional_analysis()

Error Analysis and Uncertainty

Understanding measurement uncertainty is crucial in physics:

# Error analysis and uncertainty propagation def error_analysis(): """ Demonstrate error analysis and uncertainty propagation """ print("ERROR ANALYSIS IN PHYSICS") print("="*30) # Example: Measuring gravitational acceleration # Using pendulum: g = 4π²L/T² # Measurements with uncertainties L = 1.000 # Length (m) dL = 0.001 # Uncertainty in length (m) T = 2.006 # Period (s) dT = 0.010 # Uncertainty in period (s) # Calculate g g = 4 * np.pi**2 * L / T**2 # Uncertainty propagation: g = 4π²L/T² # Relative uncertainty: δg/g = δL/L + 2δT/T relative_uncertainty = dL/L + 2*dT/T dg = g * relative_uncertainty print(f"Measurement results:") print(f"Length: L = {L:.3f} ± {dL:.3f} m") print(f"Period: T = {T:.3f} ± {dT:.3f} s") print(f"Calculated g = {g:.2f} ± {dg:.2f} m/s²") print(f"Accepted value: 9.81 m/s²") print(f"Percent error: {abs(g - 9.81)/9.81 * 100:.1f}%") # Monte Carlo error propagation def monte_carlo_errors(n_samples=10000): """Use Monte Carlo method for error propagation""" # Generate random samples L_samples = np.random.normal(L, dL, n_samples) T_samples = np.random.normal(T, dT, n_samples) # Calculate g for each sample g_samples = 4 * np.pi**2 * L_samples / T_samples**2 # Statistics g_mean = np.mean(g_samples) g_std = np.std(g_samples) print(f"\nMonte Carlo results ({n_samples} samples):") print(f"g = {g_mean:.2f} ± {g_std:.2f} m/s²") # Plot distribution plt.figure(figsize=(10, 6)) plt.subplot(1, 2, 1) plt.hist(g_samples, bins=50, density=True, alpha=0.7, edgecolor='black') plt.axvline(g_mean, color='red', linestyle='--', linewidth=2, label=f'Mean: {g_mean:.2f}') plt.axvline(9.81, color='green', linestyle='--', linewidth=2, label='True value: 9.81') plt.xlabel('g (m/s²)') plt.ylabel('Probability Density') plt.title('Distribution of g Values') plt.legend() plt.grid(True, alpha=0.3) # Error vs number of measurements plt.subplot(1, 2, 2) n_measurements = np.logspace(1, 4, 20).astype(int) standard_errors = [] for n in n_measurements: # Standard error decreases as 1/√n standard_error = g_std / np.sqrt(n) standard_errors.append(standard_error) plt.loglog(n_measurements, standard_errors, 'bo-', linewidth=2) plt.loglog(n_measurements, 1/np.sqrt(n_measurements), 'r--', linewidth=2, label='∝ 1/√n') plt.xlabel('Number of Measurements') plt.ylabel('Standard Error (m/s²)') plt.title('Error Reduction with More Measurements') plt.legend() plt.grid(True, alpha=0.3) plt.tight_layout() plt.show() return g_samples, g_mean, g_std # Execute Monte Carlo analysis g_samples, g_mean, g_std = monte_carlo_errors() return g, dg, g_samples # Execute error analysis error_results = error_analysis()

Next Steps in Your Physics Journey

Immediate Explorations

  1. Planetary Motion: Simulate orbital mechanics and Kepler's laws

  2. Wave Interference: Explore wave superposition and interference patterns

  3. Quantum Basics: Introduction to wave-particle duality

  4. Thermal Equilibrium: Statistical mechanics fundamentals

Building Toward Advanced Physics

  • Classical Field Theory: Maxwell's equations and electromagnetic waves

  • Quantum Mechanics: Schrödinger equation and quantum systems

  • Statistical Physics: Phase transitions and critical phenomena

  • Relativity: Special and general relativistic effects

Research Skills Development

  • Experimental Design: Planning and analyzing physics experiments

  • Data Analysis: Statistical methods for physics data

  • Modeling: Creating and validating physical models

  • Communication: Presenting physics results effectively

Computational physics in CoCalc opens new ways to understand the physical world. Start with fundamental concepts, build your computational skills, and gradually explore more sophisticated phenomena. The combination of theory, computation, and visualization makes complex physics accessible and engaging.


Begin your computational physics journey. Access physics simulations and start exploring at cocalc.com

AMS
Conferences
JMM
Seattle
2025-01-03

Join Us at JMM for an Exclusive Meet & Greet and Live Demo with William Stein!

We are thrilled to announce a special opportunity to meet William Stein, the CEO and Founder of CoCalc, at the JMM meeting in Seattle, WA.

Don't miss this chance to engage with William as he presents a live demo of CoCalc! With numerous publications under his belt, William previously served as a tenured professor at the University of Washington until 2019, at which point he committed full-time to growing the CoCalc Platform.

William has made significant contributions to the field of Computational Algebraic Number Theory and is the creator of the Computer Algebra System Sage.

Come find us at booth 507 in the Exhibit Hall during the Grand Opening Reception.

Getting Started with Mathematical Computing

Welcome to Mathematical Discovery

Pure mathematics—the exploration of mathematical concepts for their own beauty and elegance—has never been more accessible. CoCalc provides a comprehensive environment where you can explore algebra, number theory, geometry, and analysis without the barriers of complex software installation or expensive licenses.

For detailed information about SageMath and mathematical computing features, see the CoCalc SageMath documentation.

Whether you're a student encountering abstract mathematics for the first time, a researcher exploring new mathematical territories, or simply someone fascinated by the beauty of mathematical truth, CoCalc offers the tools you need to transform abstract concepts into concrete understanding.

Your Mathematical Toolkit

SageMath: Your Mathematical Companion

SageMath is your primary tool for mathematical exploration—a comprehensive system that combines the power of dozens of specialized mathematical packages into one unified interface.

Note: Use a SageMath kernel/worksheet for these examples, not Python.

# Welcome to mathematical computing! # Let's start with basic symbolic mathematics # Working with symbolic variables x, y, z = var('x y z') # Symbolic expressions and algebra expr = (x + 1)^3 expanded = expand(expr) factored = factor(x^3 + 3*x^2 + 3*x + 1) print("Original expression:", expr) print("Expanded form:", expanded) print("Factored form:", factored) # Basic calculus f = x^2 + 3*x + 2 derivative = diff(f, x) integral = integrate(f, x) print("\nFunction: f(x) =", f) print("Derivative: f'(x) =", derivative) print("Integral: ∫f(x)dx =", integral)

Output:

Original expression: (x + 1)^3 Expanded form: x^3 + 3*x^2 + 3*x + 1 Factored form: (x + 1)^3 Function: f(x) = x^2 + 3*x + 2 Derivative: f'(x) = 2*x + 3 Integral: ∫f(x)dx = 1/3*x^3 + 3/2*x^2 + 2*x

Exploring Number Theory

Number theory—the study of integers and their properties—comes alive with computational exploration:

# Number theory explorations print("=== NUMBER THEORY ADVENTURES ===") # Prime numbers and factorization n = 2023 print("\nIs", n, "prime?", is_prime(n)) print("Prime factorization of", n, ":", factor(n)) # Finding primes primes_up_to_100 = [p for p in range(2, 101) if is_prime(p)] print("\nFirst few primes:", primes_up_to_100[:10]) print("Number of primes up to 100:", len(primes_up_to_100)) # The Euclidean algorithm a, b = 48, 18 gcd_result = gcd(a, b) print("\ngcd(", a, ",", b, ") =", gcd_result) # Extended Euclidean algorithm g, u, v = xgcd(a, b) print("Extended:", u, "·", a, " + ", v, "·", b, " = ", g)

Output:

=== NUMBER THEORY ADVENTURES === Is 2023 prime? False Prime factorization of 2023 : 7 * 17^2 First few primes: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] Number of primes up to 100: 25 gcd( 48 , 18 ) = 6 Extended: -1 · 48 + 3 · 18 = 6

Algebraic Structures

Explore the fundamental structures that underlie mathematics:

# Group theory basics print("=== ALGEBRAIC STRUCTURES ===") # Modular arithmetic print("\nModular arithmetic:") for i in range(12): print(i, "mod 5 =", i % 5) # Working with permutations # Create a simple permutation group S3 = SymmetricGroup(3) print("\nSymmetric group S3 has order:", S3.order()) print("Elements of S3:", list(S3)) # Group operations g1 = S3([2, 1, 3]) # Swap first two elements g2 = S3([1, 3, 2]) # Swap last two elements product = g1 * g2 print("\nPermutation multiplication:") print(g1, "*", g2, "=", product)

Output:

=== ALGEBRAIC STRUCTURES === Modular arithmetic: 0 mod 5 = 0 1 mod 5 = 1 2 mod 5 = 2 3 mod 5 = 3 4 mod 5 = 4 5 mod 5 = 0 6 mod 5 = 1 7 mod 5 = 2 8 mod 5 = 3 9 mod 5 = 4 10 mod 5 = 0 11 mod 5 = 1 Symmetric group S3 has order: 6 Elements of S3: [(), (2,3), (1,2), (1,2,3), (1,3,2), (1,3)] Permutation multiplication: (1,2) * (2,3) = (1,2,3)

Calculus and Analysis

Move from discrete to continuous mathematics:

# Calculus explorations print("=== CALCULUS AND ANALYSIS ===") # Limits x = var('x') limit_expr = sin(x)/x limit_result = limit(limit_expr, x=0) print("lim(x→0) sin(x)/x =", limit_result) # Series expansions f = e^x taylor_series = f.taylor(x, 0, 5) # Taylor series around x=0, degree 5 print("\nTaylor series of e^x:", taylor_series) # Definite integrals integral_result = integrate(x^2 * e^(-x^2), x, -oo, oo) print("\n∫_{-∞}^{∞} x²e^(-x²) dx =", integral_result) # Plotting functions p1 = plot(sin(x), (x, -2*pi, 2*pi), color='blue', legend_label='sin(x)') p2 = plot(cos(x), (x, -2*pi, 2*pi), color='red', legend_label='cos(x)') combined_plot = p1 + p2 combined_plot.show()

Output:

=== CALCULUS AND ANALYSIS === lim(x0) sin(x)/x = 1 Taylor series of e^x: 1/120*x^5 + 1/24*x^4 + 1/6*x^3 + 1/2*x^2 + x + 1 _{-}^{} x²e^(-x²) dx = 1/2*sqrt(pi)

Linear Algebra: The Language of Modern Mathematics

Linear algebra provides the foundation for understanding higher mathematics:

# Linear algebra basics print("=== LINEAR ALGEBRA ===") # Matrices and vectors A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) v = vector([1, 2, 3]) print("Matrix A:") print(A) print("Vector v:", v) # Matrix operations det_A = A.determinant() print("\nDeterminant of A:", det_A) # Eigenvalues and eigenvectors B = Matrix([[2, 1], [1, 2]]) eigenvals = B.eigenvalues() eigenvects = B.eigenvectors_right() print("\nMatrix B:") print(B) print("Eigenvalues:", eigenvals) print("Eigenvectors:") for eval, evect, mult in eigenvects: print(" λ =", eval, ", v =", evect[0], ", multiplicity =", mult)

Output:

=== LINEAR ALGEBRA === Matrix A: [1 2 3] [4 5 6] [7 8 9] Vector v: (1, 2, 3) Determinant of A: 0 Matrix B: [2 1] [1 2] Eigenvalues: [3, 1] Eigenvectors: λ = 3 , v = (1, 1) , multiplicity = 1 λ = 1 , v = (1, -1) , multiplicity = 1

Mathematical Visualization

Mathematics becomes more intuitive when you can see it:

# 2D plotting x = var('x') p1 = plot(sin(x), (x, -2*pi, 2*pi), color='blue', legend_label='sin(x)') p2 = plot(cos(x), (x, -2*pi, 2*pi), color='red', legend_label='cos(x)') combined_plot = p1 + p2 combined_plot.axes_labels(['x', 'y']) combined_plot.legend(True) combined_plot.show(title='Trigonometric Functions') # 3D surface x, y = var('x y') surface_plot = plot3d(x^2 + y^2, (x, -2, 2), (y, -2, 2)) surface_plot.show()

Getting Started: Your First Mathematical Explorations

Exercise 1: Number Theory Investigation

# Investigate perfect numbers def is_perfect(n): """Check if n is a perfect number""" divisors = [i for i in range(1, n) if n % i == 0] return sum(divisors) == n # Find perfect numbers up to 100 perfect_numbers = [n for n in range(1, 101) if is_perfect(n)] print("Perfect numbers up to 100:", perfect_numbers) # Investigate their properties for p in perfect_numbers: divisors = [i for i in range(1, p) if p % i == 0] print(p, ": divisors =", divisors, ", sum =", sum(divisors))

Output:

Perfect numbers up to 100: [6, 28] 6 : divisors = [1, 2, 3] , sum = 6 28 : divisors = [1, 2, 4, 7, 14] , sum = 28

Exercise 2: Polynomial Exploration

# Explore polynomial behavior x = var('x') polynomials = [ x^2 - 1, # Quadratic x^3 - 3*x + 1, # Cubic x^4 - 5*x^2 + 6 # Quartic ] for poly in polynomials: print("\nPolynomial:", poly) # Find roots roots = solve(poly == 0, x) print("Roots:", roots) # Factor if possible try: factored = factor(poly) print("Factored form:", factored) except: print("Cannot factor over rationals") # Plot the polynomial plot(poly, (x, -3, 3)).show()

Output:

Polynomial: x^2 - 1 Roots: [x == -1, x == 1] Factored form: (x - 1)*(x + 1) Polynomial: x^3 - 3*x + 1 Roots: [x == -1/2*sqrt(5) - 1/2, x == 1/2*sqrt(5) - 1/2, x == 1] Factored form: x^3 - 3*x + 1 Polynomial: x^4 - 5*x^2 + 6 Roots: [x == -sqrt(3), x == sqrt(3), x == -sqrt(2), x == sqrt(2)] Factored form: (x^2 - 3)*(x^2 - 2)

Exercise 3: Matrix Magic

# Explore special matrices print("=== SPECIAL MATRICES ===") # Identity matrix I = identity_matrix(3) print("Identity matrix:") print(I) # Rotation matrix (2D) angle = pi/4 # 45 degrees rotation_2d = Matrix([[cos(angle), -sin(angle)], [sin(angle), cos(angle)]]) print("\n45° rotation matrix:") print(rotation_2d) # Apply rotation to a vector v = vector([1, 0]) rotated_v = rotation_2d * v print("Original vector:", v) print("Rotated vector:", rotated_v) # Verify the rotation preserves length print("Original length:", v.norm()) print("Rotated length:", rotated_v.norm())

Output:

=== SPECIAL MATRICES === Identity matrix: [1 0 0] [0 1 0] [0 0 1] 45° rotation matrix: [1/2*sqrt(2) -1/2*sqrt(2)] [1/2*sqrt(2) 1/2*sqrt(2)] Original vector: (1, 0) Rotated vector: (1/2*sqrt(2), 1/2*sqrt(2)) Original length: 1 Rotated length: 1

Building Mathematical Intuition

Understanding Through Computation

Mathematical intuition develops through active exploration. Use CoCalc to:

  1. Test Conjectures: Try examples and look for patterns

  2. Visualize Concepts: Plot functions and geometric objects

  3. Verify Calculations: Check hand computations with symbolic math

  4. Explore Edge Cases: See what happens at boundaries and special values

Example: The Fibonacci Sequence

# Fibonacci explorations def fibonacci_sequence(n): """Generate first n Fibonacci numbers""" fib = [1, 1] for i in range(2, n): fib.append(fib[i-1] + fib[i-2]) return fib # Generate Fibonacci numbers fib_nums = fibonacci_sequence(20) print("First 20 Fibonacci numbers:", fib_nums) # Investigate the golden ratio connection golden_ratio = (1 + sqrt(5))/2 ratios = [fib_nums[i+1]/fib_nums[i] for i in range(len(fib_nums)-1)] print("\nGolden ratio:", float(golden_ratio)) print("Consecutive Fibonacci ratios:") for i, ratio in enumerate(ratios[-10:], len(ratios)-9): print("F(", i+1, ")/F(", i, ") =", float(ratio)) # Plot convergence to golden ratio data_points = [(i, float(ratios[i-1])) for i in range(1, len(ratios)+1)] ratio_plot = list_plot(data_points, color='blue', plotjoined=True, legend_label='F(n+1)/F(n)') ratio_plot += line([(1, float(golden_ratio)), (len(ratios), float(golden_ratio))], color='red', linestyle='--', legend_label='Golden Ratio') ratio_plot.axes_labels(['n', 'Ratio']) ratio_plot.title('Fibonacci Ratios Converging to Golden Ratio') ratio_plot.show()

Next Steps in Your Mathematical Journey

Immediate Explorations

  1. Prime Number Patterns: Investigate prime gaps and distributions

  2. Geometric Sequences: Explore convergence and divergence

  3. Function Transformations: See how parameters affect graphs

  4. Matrix Powers: Discover patterns in repeated matrix multiplication

Preparing for Advanced Topics

  • Abstract Algebra: Group and ring theory

  • Real Analysis: Rigorous foundations of calculus

  • Complex Analysis: Functions of complex variables

  • Topology: Properties preserved under continuous deformations

Mathematical Research Skills

  • Conjecture Formation: Making educated mathematical guesses

  • Proof Techniques: Direct, indirect, and inductive reasoning

  • Mathematical Writing: Communicating ideas clearly

  • Collaboration: Working with others on mathematical problems

Resources for Continued Learning

Documentation and Help

  • SageMath Documentation: Comprehensive guides and examples

  • CoCalc Help: Platform-specific tutorials and tips

  • Mathematical Communities: Online forums and discussion groups

Practice Problems

  • Project Euler: Computational mathematics challenges

  • Mathematical Olympiad Problems: Contest mathematics

  • Research Papers: Current mathematical investigations

Pure mathematics in CoCalc opens doors to a universe of mathematical beauty and discovery. Start with simple explorations, build your computational skills, and gradually tackle more sophisticated problems. Every mathematician started with curiosity—let CoCalc help you transform that curiosity into deep mathematical understanding.


Begin your mathematical journey today. Access SageMath and start exploring at cocalc.com