instruction
stringlengths
2.01k
8.44k
input
stringclasses
1 value
output
stringlengths
180
2.3k
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def cone_volume_error(r, h, dr, dh): '''Estimate the maximum error in the calculated volume of a cone. Inputs: r: base radius of the cone in cm, float h: height of the cone in cm, float dr: maximum error in the measurement of the radius in cm, float dh: maximum error in the measurement of the he...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def initial_velocity_components(v0, theta_deg): '''Compute the initial horizontal and vertical velocity components. Inputs: v0: initial speed in m/s, float theta_deg: angle of elevation in degrees, float Outputs: vx0: initial horizontal velocity component in m/s, float vy0: initial vertical ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def time_of_flight(vy0, g): '''Compute the total time of flight of the projectile. Inputs: vy0: initial vertical velocity component in m/s, float g: acceleration due to gravity in m/s^2, float Outputs: t_flight: total time of flight in seconds, float ''' t_flight = 2.0 * vy0 / g retu...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def final_velocity_components(vx0, vy0, t_flight, g): '''Compute the final horizontal and vertical velocity components at impact. Inputs: vx0: initial horizontal velocity component in m/s, float vy0: initial vertical velocity component in m/s, float t_flight: total time of flight in seconds, float ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def impact_speed_magnitude(vxf, vyf): '''Compute the magnitude of the final velocity vector at impact. Inputs: vxf: final horizontal velocity component in m/s, float vyf: final vertical velocity component in m/s, float Outputs: speed: final speed at impact in m/s, float ''' speed = math....
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def solve_projectile_impact(v0, theta_deg, g=9.8): '''Determine the speed of the projectile at impact. Inputs: v0: initial speed in m/s, float theta_deg: angle of elevation in degrees, float g: acceleration due to gravity in m/s^2, float Outputs: final_speed: speed of the projectile at impac...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def compute_subrectangle_area(x_domain, y_domain, m, n): '''Compute the area of a single sub-rectangle. Inputs: x_domain: tuple of two floats, (x_min, x_max) y_domain: tuple of two floats, (y_min, y_max) m: int, number of subintervals along x n: int, number of subintervals along y Output: ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def generate_sample_points(x_domain, y_domain, m, n): '''Generate the sample points (upper right corners) for the Riemann sum. Inputs: x_domain: tuple of two floats, (x_min, x_max) y_domain: tuple of two floats, (y_min, y_max) m: int, number of subintervals along x n: int, number of subintervals...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def evaluate_surface_height(x, y): '''Evaluate the height of the paraboloid at a given point. Inputs: x: float, x-coordinate y: float, y-coordinate Output: z: float, height of the surface ''' z = 16.0 - x**2 - 2.0 * y**2 return z
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def estimate_volume(x_domain, y_domain, m, n): '''Estimate the volume of the solid using a Riemann sum. Inputs: x_domain: tuple of two floats, (x_min, x_max) y_domain: tuple of two floats, (y_min, y_max) m: int, number of subintervals along x n: int, number of subintervals along y Output: ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def convert_wavelength_to_meters(wavelength_pm): '''Convert wavelength from picometers to meters. Inputs: wavelength_pm: wavelength in picometers, float Output: wavelength_m: wavelength in meters, float ''' wavelength_m = float(wavelength_pm) * 1e-12 return wavelength_m
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def compute_neutron_velocity(wavelength_m, mass, h): '''Compute the velocity of a neutron from its de Broglie wavelength. Inputs: wavelength_m: de Broglie wavelength in meters, float mass: mass of the neutron in kg, float h: Planck constant in J*s, float Output: velocity: velocity of the neu...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def compute_temperature_from_velocity(velocity, mass, k_B): '''Compute the temperature corresponding to a given neutron velocity. Inputs: velocity: velocity of the neutron in m/s, float mass: mass of the neutron in kg, float k_B: Boltzmann constant in J/K, float Output: temperature: required...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def neutron_beam_temperature(wavelength_pm, mass, h, k_B): '''Calculate the required temperature for a neutron beam to have a specific de Broglie wavelength. Inputs: wavelength_pm: target de Broglie wavelength in picometers, float mass: mass of a neutron in kg, float h: Planck constant in J*s, float...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def compute_k(theta, N, d, lambda_wave): '''Compute the parameter k for the diffraction grating. Inputs: theta: angle in radians, float N: number of slits, int d: distance between adjacent slits in meters, float lambda_wave: wavelength of the light in meters, float Output: k: computed pa...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def compute_intensity(k, N): '''Compute the intensity of light for a given k and N. Inputs: k: phase-related parameter, float N: number of slits, int Output: intensity: computed light intensity, float ''' if N == 0: return 0.0 if abs(k) < 1e-10: return float(N**2) ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def generate_midpoints(a, b, n): '''Generate the midpoints and subinterval width for the Midpoint Rule. Inputs: a: lower limit of integration, float b: upper limit of integration, float n: number of subintervals, int Output: midpoints: list or 1D numpy array of midpoints, list of floats ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def estimate_total_intensity(a, b, n, N, d, lambda_wave): '''Estimate the total light intensity using the Midpoint Rule. Inputs: a: lower limit of integration for theta, float b: upper limit of integration for theta, float n: number of subintervals, int N: number of slits, int d: distance be...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def compute_grid_parameters(x_start, x_end, m, y_start, y_end, n): '''Compute the midpoints and subrectangle area for the grid. Inputs: x_start: lower bound of x, float x_end: upper bound of x, float m: number of subintervals in x, int y_start: lower bound of y, float y_end: upper bound of y...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def evaluate_integrand(x, y): '''Evaluate the function f(x, y) = x - 3y^2. Inputs: x: x-coordinate, float y: y-coordinate, float Outputs: f_val: value of the function at (x, y), float ''' f_val = float(x - 3 * y**2) return f_val
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def apply_midpoint_rule(x_midpoints, y_midpoints, delta_A): '''Compute the double Riemann sum using the Midpoint Rule. Inputs: x_midpoints: list of midpoints in x-direction, list of floats y_midpoints: list of midpoints in y-direction, list of floats delta_A: area of each subrectangle, float Out...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def estimate_double_integral(x_start, x_end, m, y_start, y_end, n): '''Estimate the double integral of x - 3y^2 over the specified region. Inputs: x_start: lower bound of x, float x_end: upper bound of x, float m: number of subintervals in x, int y_start: lower bound of y, float y_end: upper...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def compute_cylinder_surface_area(R, L): '''Compute the lateral surface area of a cylinder. Inputs: R: radius of the cylinder, float L: length of the cylinder, float Output: area: lateral surface area, float ''' area = 2 * math.pi * R * L return area
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def compute_inward_normal_derivative(c, R): '''Compute the directional derivative of temperature along the inward normal. Inputs: c: coefficient in the temperature function, float R: radius of the cylinder, float Output: du_dn_in: inward normal derivative of temperature, float ''' du_dn_...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def compute_inward_heat_flux_density(K, du_dn_in): '''Compute the inward heat flux density using Fourier's law. Inputs: K: thermal conductivity, float du_dn_in: inward normal derivative of temperature, float Output: q_in: inward heat flux density, float ''' q_in = -K * du_dn_in retur...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def compute_total_heat_flow(q_in, area): '''Compute the total rate of heat flow across the surface. Inputs: q_in: inward heat flux density, float area: surface area of the cylinder, float Output: total_heat_flow: total rate of heat flow, float ''' total_heat_flow = float(q_in * area) ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def solve_heat_flow_problem(c, K, R_sq, L): '''Solve for the total rate of heat flow inward across the cylindrical surface. Inputs: c: coefficient in the temperature function, float K: thermal conductivity, float R_sq: squared radius of the cylinder, float L: length of the cylinder, float Ou...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def generate_grid(a, b, n): '''Calculate the step size and generate grid points for numerical integration. Inputs: a: lower limit of integration, float b: upper limit of integration, float n: number of subintervals, int Outputs: x_points: array of grid points, numpy array of floats delta...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def evaluate_function(x_points): '''Evaluate the function f(x) = 1/x at the given grid points. Inputs: x_points: array of grid points, numpy array of floats Outputs: y_values: array of evaluated function values, numpy array of floats ''' x_arr = np.asarray(x_points, dtype=float) y_values...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def apply_simpsons_rule(y_values, delta_x): '''Compute the integral approximation using Simpson's Rule. Inputs: y_values: array of evaluated function values, numpy array of floats delta_x: step size, float Outputs: integral_approx: approximated value of the integral, float ''' y_arr = np...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def approximate_integral(a, b, n): '''Approximate the integral of 1/x from a to b using Simpson's Rule with n subintervals. Inputs: a: lower limit of integration, float b: upper limit of integration, float n: number of subintervals (must be even), int Outputs: final_result: the approximated ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def calculate_extensions(natural_length_cm, length1_cm, length2_cm): '''Calculate the extensions of the spring in meters. Inputs: natural_length_cm: natural length in cm, float length1_cm: first stretched length in cm, float length2_cm: second stretched length in cm, float Outputs: extension...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def compute_spring_constant(force_n, extension1_m): '''Compute the spring constant using Hooke's Law. Inputs: force_n: force applied in Newtons, float extension1_m: extension of the spring in meters, float Outputs: spring_constant: spring constant in N/m, float ''' if extension1_m == 0.0...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def compute_work_done(spring_constant, extension1_m, extension2_m): '''Calculate the work done in stretching the spring. Inputs: spring_constant: spring constant in N/m, float extension1_m: initial extension in meters, float extension2_m: final extension in meters, float Outputs: work_joules...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def solve_spring_work(natural_length_cm, length1_cm, force_n, length2_cm): '''Solve for the total work done in stretching the spring. Inputs: natural_length_cm: natural length in cm, float length1_cm: first stretched length in cm, float force_n: force at first stretched length in N, float length...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def get_velocity_vectors(v_woman, v_ship): '''Construct the velocity vectors for the woman and the ship. Inputs: v_woman: speed of the woman walking due west, float v_ship: speed of the ship moving north, float Outputs: v_ws: velocity vector of the woman relative to the ship, tuple of two floats...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def compute_relative_speed(v_ws, v_sw): '''Compute the speed of the woman relative to the water. Inputs: v_ws: velocity vector of the woman relative to the ship, tuple of two floats v_sw: velocity vector of the ship relative to the water, tuple of two floats Outputs: speed: speed of the woman re...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def solve_relative_speed(v_woman, v_ship): '''Solve for the speed of the woman relative to the water. Inputs: v_woman: speed of the woman walking due west, float v_ship: speed of the ship moving north, float Outputs: final_speed: the speed of the woman relative to the surface of the water, float...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def ground_hit_distance(H, k): '''Calculate the horizontal distance where the prey hits the ground. Inputs: H: initial altitude in meters, float k: parabolic coefficient, float Output: x_max: horizontal distance at impact in meters, float ''' import math return float(math.sqrt(H / k)...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def arc_length_integrand(x, k): '''Compute the integrand for the arc length of the parabolic trajectory. Inputs: x: horizontal position in meters, float k: parabolic coefficient, float Output: integrand_value: value of the integrand at x, float ''' integrand_value = (1.0 + 4.0 * (k ** 2)...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def compute_arc_length(x_max, k): '''Compute the arc length of the trajectory up to x_max. Inputs: x_max: upper limit of integration (horizontal distance), float k: parabolic coefficient, float Output: arc_length: computed arc length in meters, float ''' from scipy import integrate a...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def prey_travel_distance(H, k): '''Calculate the total distance traveled by the prey along its trajectory. Inputs: H: initial altitude in meters, float k: parabolic coefficient, float Output: total_distance: total distance traveled in meters, float ''' if H == 0: return 0.0 x...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def time_of_flight(v0_z, a_z): '''Calculate the time of flight. Inputs: v0_z: vertical component of initial velocity, float a_z: vertical component of acceleration, float Output: t: time of flight, float ''' if a_z == 0: if v0_z == 0: t = float('nan') else: ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def velocity_at_time(v0, a, t): '''Calculate the velocity vector at time t. Inputs: v0: initial velocity vector (v0_x, v0_y, v0_z), tuple of floats a: constant acceleration vector (a_x, a_y, a_z), tuple of floats t: time, float Output: v: velocity vector at time t (v_x, v_y, v_z), tuple of f...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def speed_from_velocity(v): '''Calculate the speed from a velocity vector. Inputs: v: velocity vector (v_x, v_y, v_z), tuple of floats Output: speed: magnitude of the velocity vector, float ''' import math speed = math.sqrt(v[0]**2 + v[1]**2 + v[2]**2) return speed
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def landing_speed(v0, a): '''Calculate the landing speed of the ball. Inputs: v0: initial velocity vector (v0_x, v0_y, v0_z) in ft/s, tuple of floats a: constant acceleration vector (a_x, a_y, a_z) in ft/s^2, tuple of floats Output: speed: landing speed in ft/s, float ''' if a[2] == 0 an...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def compute_curl(x, y, z): '''Compute the curl of the vector field F = xy i + yz j + zx k. Inputs: x: x-coordinate, float y: y-coordinate, float z: z-coordinate, float Output: curl: a tuple of three floats representing the (x, y, z) components of the curl ''' curl_x = float(-y) c...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def surface_normal_and_z(x, y, a, b, c): '''Compute the z-coordinate and the unnormalized normal vector of the plane. Inputs: x: x-coordinate, float y: y-coordinate, float a: x-intercept, float b: y-intercept, float c: z-intercept, float Output: z_val: z-coordinate on the plane, floa...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def integrand_2d(y, x, a, b, c): '''Compute the dot product of the curl and the normal vector at a given (x,y). Note the parameter order (y, x) is designed for scipy.integrate.dblquad. Inputs: y: y-coordinate, float x: x-coordinate, float a: x-intercept, float b: y-intercept, float c: z-...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def evaluate_stokes_integral(a, b, c): '''Evaluate the line integral using Stokes' Theorem by integrating over the projected triangle. Inputs: a: x-intercept, float b: y-intercept, float c: z-intercept, float Output: integral_value: the evaluated integral, float ''' integral_value, e...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def convert_wavelength_to_meters(lambda_nm): '''Convert wavelength from nanometers to meters. Inputs: lambda_nm: peak wavelength in nanometers, float Output: lambda_m: wavelength in meters, float ''' lambda_m = lambda_nm * 1e-9 return lambda_m
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def calculate_blackbody_temperature(lambda_m, b_constant): '''Calculate the temperature of a blackbody given its peak wavelength. Inputs: lambda_m: peak wavelength in meters, float b_constant: Wien's displacement constant in m*K, float Output: temperature: surface temperature in Kelvin, float ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def estimate_star_temperature(lambda_nm): '''Estimate the surface temperature of a star based on its peak wavelength. Inputs: lambda_nm: peak wavelength in nanometers, float Output: temperature: surface temperature in Kelvin, float ''' lambda_m = convert_wavelength_to_meters(lambda_nm) b...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def convert_to_meters(wavelength_nm, fringe_spacing_cm): '''Convert wavelength and fringe spacing to meters. Inputs: wavelength_nm: wavelength in nanometers, float fringe_spacing_cm: fringe spacing in centimeters, float Outputs: wavelength_m: wavelength in meters, float fringe_spacing_m: fri...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def compute_slit_distance_m(wavelength_m, screen_distance_m, fringe_spacing_m): '''Calculate the slit distance in meters using the interference formula. Inputs: wavelength_m: wavelength in meters, float screen_distance_m: distance to the screen in meters, float fringe_spacing_m: distance between adj...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def convert_to_millimeters(slit_distance_m): '''Convert the slit distance from meters to millimeters. Inputs: slit_distance_m: distance between the slits in meters, float Outputs: slit_distance_mm: distance between the slits in millimeters, float ''' slit_distance_mm = float(slit_distance_m ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def solve_double_slit(wavelength_nm, screen_distance_m, fringe_spacing_cm): '''Calculate the distance between two slits in millimeters given the interference pattern parameters. Inputs: wavelength_nm: wavelength of the laser light in nanometers, float screen_distance_m: distance from the slits to the sc...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def force_magnitude(x, k, p): '''Compute the magnitude of the force at position x. Inputs: x: position, float k: force coefficient, float p: force exponent, float Output: force: magnitude of the force, float ''' abs_x = abs(x) abs_k = abs(k) if abs_x == 0.0: if p...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def antiderivative_power_law(x, k, p): '''Evaluate the antiderivative of the force function at position x. Inputs: x: position, float k: force coefficient, float p: force exponent, float Output: antiderivative_val: value of the antiderivative at x, float ''' import math exponent ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def calculate_work_done(a, b, k, p): '''Calculate the total work done by the force from x=a to x=b. Inputs: a: initial position, float b: final position, float k: force coefficient, float p: force exponent, float Output: work: total work done, float ''' if a == b: return ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def find_integration_bounds(p, q): '''Determine the integration bounds by finding the intersection points of y=x^p and y=x^q. Inputs: p: exponent of the first curve, float q: exponent of the second curve, float Outputs: bounds: a tuple containing (lower_bound, upper_bound), tuple of floats '...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to de...
def cross_sectional_area(x, p, q): '''Compute the cross-sectional area of the solid of revolution at point x. Inputs: x: the x-coordinate, float p: exponent of the upper curve, float q: exponent of the lower curve, float Outputs: area: the cross-sectional area at x, float ''' import ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to de...
def compute_volume(p, q, lower_bound, upper_bound): '''Compute the total volume by integrating the cross-sectional area. Inputs: p: exponent of the upper curve, float q: exponent of the lower curve, float lower_bound: lower limit of integration, float upper_bound: upper limit of integration, flo...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to de...
def solve_volume_of_revolution(p, q): '''Calculate the volume of the solid of revolution generated by y=x^p and y=x^q. Inputs: p: exponent of the upper curve, float q: exponent of the lower curve, float Outputs: total_volume: the final computed volume, float ''' if p == q: return...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def find_intersections(coeffs1, coeffs2): '''Find the intersection points of two parabolas. Inputs: coeffs1: tuple of floats (a1, b1, c1) for y = a1*x^2 + b1*x + c1 coeffs2: tuple of floats (a2, b2, c2) for y = a2*x^2 + b2*x + c2 Output: roots: tuple of floats (x1, x2) representing the x-coordin...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to fi...
def evaluate_difference(x, coeffs1, coeffs2): '''Evaluate the absolute difference between two parabolas at a given x. Inputs: x: the x-coordinate to evaluate at, float coeffs1: tuple of floats (a1, b1, c1) coeffs2: tuple of floats (a2, b2, c2) Output: difference: the absolute difference |y1(...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to fi...
def calculate_enclosed_area(coeffs1, coeffs2, limits): '''Calculate the area enclosed by two parabolas. Inputs: coeffs1: tuple of floats (a1, b1, c1) coeffs2: tuple of floats (a2, b2, c2) limits: tuple of floats (x1, x2) representing the integration limits Output: area: the computed enclosed...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to fi...
def solve_area_problem(): '''Solve for the area enclosed by y = x^2 and y = 2x - x^2. Inputs: None Output: final_area: the area of the enclosed region, float ''' coeffs1 = (1.0, 0.0, 0.0) coeffs2 = (-1.0, 2.0, 0.0) limits = find_intersections(coeffs1, coeffs2) final_area = c...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def compute_charge_and_energy(charge_number, elementary_charge, potential_difference): '''Compute the charge and kinetic energy gained by the particle. Inputs: charge_number: number of elementary charges, int elementary_charge: elementary charge in Coulombs, float potential_difference: potential dif...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def compute_kinematics(energy, mass, scale_factor=1.0): '''Compute the velocity and momentum of the particle. Inputs: energy: kinetic energy in Joules, float mass: mass of the particle in kg, float scale_factor: optional scaling factor for unit conversions, float Outputs: velocity: final vel...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def analyze_alpha_particle(charge_number, elementary_charge, potential_difference, mass): '''Analyze the energy and kinematics of an accelerated alpha particle. Inputs: charge_number: number of elementary charges, int elementary_charge: elementary charge in Coulombs, float potential_difference: pote...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def taylor_ln_1_plus_x(n): '''Compute the Taylor series coefficients of ln(1+x) up to order n. Inputs: n: maximum order of the expansion, integer Output: coeffs: list of coefficients from order 0 to n, list of floats ''' coeffs = [0.0] for k in range(1, n + 1): if k % 2 == 1: ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def numerator_coeffs(n): '''Compute the Taylor series coefficients of ln(1+x) - x up to order n. Inputs: n: maximum order of the expansion, integer Output: num_coeffs: list of coefficients from order 0 to n, list of floats ''' num_coeffs = taylor_ln_1_plus_x(n) if n >= 1: num_coe...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def evaluate_limit(num_coeffs, den_coeffs): '''Evaluate the limit given numerator and denominator Taylor coefficients. Inputs: num_coeffs: Taylor coefficients of the numerator, list of floats den_coeffs: Taylor coefficients of the denominator, list of floats Output: limit_val: the evaluated limi...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def solve_limit_problem(n): '''Solve the limit problem by combining the previous steps. Inputs: n: maximum order of the expansion, integer Output: final_limit: the evaluated limit, float ''' den_coeffs = [0.0] * (n + 1) if n >= 2: den_coeffs[2] = 1.0 num_coeffs = num...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def compute_logistic_A(N, I0): '''Compute the integration constant A for the logistic growth model. Inputs: N: total population, int I0: initial number of infected people at t=0, int Output: integration constant A, float ''' if I0 == 0: return float('inf') A = (N - I0) / I0 r...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def compute_growth_rate(N, I1, t1, A): '''Compute the effective growth rate K for the logistic model. Inputs: N: total population, int I1: number of infected people at time t1, int t1: time at which the number of infected people is I1, float A: integration constant, float Output: effective g...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def compute_target_time(N, I_target, A, K): '''Compute the time required to reach a target number of infected people. Inputs: N: total population, int I_target: target number of infected people, float A: integration constant, float K: effective growth rate, float Output: time required to rea...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def epidemic_spread_time(N, I0, I1, t1, target_ratio): '''Calculates the time required for a target fraction of the population to become infected. Inputs: N: total population, int I0: number of infected people at t=0, int I1: number of infected people at t=t1, int t1: time at which the number of...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def compute_kinetic_energy_joules(voltage_V, charge_C): '''Calculate the kinetic energy of a charged particle accelerated by a voltage. Inputs: voltage_V: voltage increment in Volts, float charge_C: charge of the particle in Coulombs, float Output: energy_J: kinetic energy in Joules, float '...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def scale_energy(energy_J, scale_factor): '''Scale the energy value by a given factor. Inputs: energy_J: energy in Joules, float scale_factor: the factor to multiply the energy by, float Output: scaled_energy: scaled energy value, float ''' scaled_energy = float(energy_J * scale_factor) ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to ca...
def electron_kinetic_energy(voltage_V): '''Calculate the scaled kinetic energy of an electron accelerated by a voltage. Inputs: voltage_V: voltage increment in Volts, float Output: final_scaled_energy: kinetic energy in units of 10^{-17} J, float ''' charge_C = 1.602176634e-19 scale_fact...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def convert_units(energy_mJ, wavelength_um): '''Convert energy and wavelength to SI units. Inputs: energy_mJ: total energy in millijoules, float wavelength_um: wavelength in micrometers, float Outputs: energy_J: total energy in Joules, float wavelength_m: wavelength in meters, float ''' ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def photon_energy(wavelength_m): '''Calculate the energy of a single photon. Inputs: wavelength_m: wavelength of the light in meters, float Outputs: energy_per_photon_J: energy of a single photon in Joules, float ''' h = 6.626e-34 c = 2.998e8 energy_per_photon_J = h * c / wavelength_...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def count_photons(total_energy_J, energy_per_photon_J): '''Calculate the total number of photons. Inputs: total_energy_J: total energy of the pulse in Joules, float energy_per_photon_J: energy of a single photon in Joules, float Outputs: num_photons: total number of photons, float ''' if...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def total_photons_in_pulse(energy_mJ, wavelength_um): '''Compute the total number of photons in a light pulse. Inputs: energy_mJ: total energy of the light pulse in millijoules, float wavelength_um: wavelength of the light in micrometers, float Outputs: num_photons: total number of photons in th...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def compute_total_mass(m1, m2, unit_factor): '''Compute the total mass of a two-body system and scale it by a unit factor. Inputs: m1: mass of the first atom, float m2: mass of the second atom, float unit_factor: scaling factor for unit conversion, float Output: total_mass: the scaled total ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def compute_reduced_mass(m1, m2, total_mass): '''Compute the reduced mass of a two-body system. Inputs: m1: mass of the first atom (unscaled), float m2: mass of the second atom (unscaled), float total_mass: scaled total mass of the system, float Output: reduced_mass: the scaled reduced mass ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def nitrogen_reduced_mass(m1, m2, unit_factor): '''Calculate the reduced mass of a diatomic molecule. Inputs: m1: mass of the first nitrogen atom, float m2: mass of the second nitrogen atom, float unit_factor: scaling factor for unit conversion, float Output: final_reduced_mass: the reduced ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def compute_exponential_and_approximation(x): '''Compute the exact value of e^x and its first-order approximation 1+x. Inputs: x: the value at which to evaluate the functions, float Outputs: exact_val: the exact value of e^x, float approx_val: the approximated value 1+x, float ''' import...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def calculate_percentage_difference(exact_val, approx_val): '''Calculate the percentage difference between an exact value and an approximation. Inputs: exact_val: the exact value, float approx_val: the approximated value, float Outputs: percentage_diff: the percentage difference, float ''' ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def solve_taylor_approximation_error(x): '''Calculate the percentage difference between e^x and 1+x for a given x. Inputs: x: the value at which to evaluate the functions, float Outputs: final_percentage_diff: the percentage difference, float ''' exact_val, approx_val = compute_exponential_a...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def max_second_derivative(a, b): '''Compute the maximum absolute value of the second derivative of 1/x on [a, b]. Inputs: a: lower limit of integration, float b: upper limit of integration, float Outputs: K: maximum absolute value of the second derivative, float ''' val_a = abs(2.0 / (a ...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def min_n_trapezoidal(K, a, b, tolerance): '''Calculate the minimum number of subintervals for the Trapezoidal Rule. Inputs: K: maximum absolute value of the second derivative, float a: lower limit of integration, float b: upper limit of integration, float tolerance: maximum allowable error, flo...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def solve_integration_error(a, b, tolerance): '''Determine the minimum number of subintervals to achieve the desired accuracy. Inputs: a: lower limit of integration, float b: upper limit of integration, float tolerance: maximum allowable error, float Outputs: min_n: minimum number of subinte...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def convert_wavelength_to_meters(wavelength_pm): '''Convert wavelength from picometers to meters. Inputs: wavelength_pm: wavelength in picometers, float Outputs: wavelength_m: wavelength in meters, float ''' wavelength_m = float(wavelength_pm) * 1e-12 return wavelength_m
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def calculate_frequency(wavelength_m, c): '''Calculate the frequency of a photon from its wavelength. Inputs: wavelength_m: wavelength in meters, float c: speed of light in m/s, float Outputs: frequency: frequency in Hz, float ''' if wavelength_m == 0: if c > 0: retur...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def calculate_energy_from_frequency(frequency, h): '''Calculate the energy of a photon from its frequency. Inputs: frequency: frequency in Hz, float h: Planck's constant in J*s, float Outputs: energy: energy in Joules, float ''' energy = float(h) * float(frequency) return energy
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: Write a function to co...
def photon_energy_scaled(wavelength_pm): '''Calculate the scaled energy of a photon given its wavelength in pm. Inputs: wavelength_pm: wavelength in picometers, float Outputs: energy_scaled: energy in units of 10^{-15} J, float ''' c = 2.9979e8 h = 6.626e-34 wavelength_m = conve...
PROBLEM DESCRIPTION: You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step. PREVIOUS STEPS DESCRIPTION: NEXT STEP - PROBLEM ...
def compute_gravitational_parameter(G, M): '''Compute the standard gravitational parameter of a celestial body. Inputs: G: universal gravitational constant in m^3/(kg s^2), float M: mass of the body in kg, float Output: mu: standard gravitational parameter in m^3/s^2, float ''' mu = G * ...