ExprUA Editor

Standard Library Overview

The ExprUA Standard Library provides a comprehensive collection of mathematical and scientific functions organized into modules. These functions are designed to handle common calculations in geometry, kinematics, mechanics, and thermodynamics with full unit support and dimensional consistency.

Available Modules

The Standard Library is organized into the following modules:

All functions in the Standard Library support ExprUA's unit system, ensuring dimensional consistency and automatic unit conversion. Functions are designed to be intuitive and follow standard mathematical notation.

geometry

Geometry Functions

Common formulas for calculating areas, volumes, and perimeters

Annulus (ring)

  • area_annulus(outer_radius: m, inner_radius: m) -> m^2
  • perimeter_annulus(outer_radius: m, inner_radius: m) -> m

Circle Functions

  • area_circle(radius: m) -> m^2
  • circumference_circle(radius: m) -> m
  • area_circle_sector(radius: m, angle_radians: dimensionless) -> m^2
  • arc_length_circle_sector(radius: m, angle_radians: dimensionless) -> m
  • area_circle_segment(radius: m, angle_radians: dimensionless) -> m^2

Cone Functions

  • volume_cone(radius: m, height: m) -> m^3
  • surface_area_cone(radius: m, height: m) -> m^2 - Total surface area = πr² + πr√(r² + h²)
  • lateral_surface_area_cone(radius: m, height: m) -> m^2 - Lateral surface area = πr√(r² + h²)

Cylinder Functions

  • volume_cylinder(radius: m, height: m) -> m^3
  • surface_area_cylinder(radius: m, height: m) -> m^2 - Total surface area = 2πr² + 2πrh = 2πr(r + h)
  • lateral_surface_area_cylinder(radius: m, height: m) -> m^2 - Lateral surface area = 2πrh

Ellipse Functions

  • area_ellipse(semi_major_axis: m, semi_minor_axis: m) -> m^2
  • perimeter_ellipse(semi_major_axis: m, semi_minor_axis: m) -> m - Approximation: Ramanujan's approximation

Ellipsoid Functions

  • volume_ellipsoid(semi_axis_a: m, semi_axis_b: m, semi_axis_c: m) -> m^3

Kite Functions

  • area_kite(diagonal1: m, diagonal2: m) -> m^2

Parallelogram Functions

  • area_parallelogram(base: m, height: m) -> m^2

Pyramid Functions

  • volume_pyramid_square_base(base_side: m, height: m) -> m^3
  • volume_pyramid_rectangular_base(length: m, width: m, height: m) -> m^3
  • surface_area_pyramid_square_base(base_side: m, height: m) -> m^2 - Total surface area = base area + 4 triangular faces

Rectangle Functions

  • area_rectangle(length: m, width: m) -> m^2
  • perimeter_rectangle(length: m, width: m) -> m
  • area_square(side: m) -> m^2 - Square functions (special case of rectangle)
  • perimeter_square(side: m) -> m

Rectangular Prism Functions

  • volume_rectangular_prism(length: m, width: m, height: m) -> m^3
  • surface_area_rectangular_prism(length: m, width: m, height: m) -> m^2
  • volume_cube(side: m) -> m^3 - Cube functions (special case of rectangular prism)
  • surface_area_cube(side: m) -> m^2

Regular Polygon Convenience Functions

  • area_regular_hexagon(side: m) -> m^2 - Area = (3√3/2) * s²
  • perimeter_regular_hexagon(side: m) -> m
  • area_regular_pentagon(side: m) -> m^2 - Area = (1/4) * √(5(5+2√5)) * s²
  • perimeter_regular_pentagon(side: m) -> m

Regular Polygon Functions

  • area_regular_polygon(side_length: m, num_sides: dimensionless) -> m^2
  • perimeter_regular_polygon(side_length: m, num_sides: dimensionless) -> m

Regular Polyhedron Functions

  • volume_regular_tetrahedron(edge_length: m) -> m^3 - Volume = (√2/12) * a³
  • surface_area_regular_tetrahedron(edge_length: m) -> m^2 - Surface area = √3 * a²
  • volume_regular_octahedron(edge_length: m) -> m^3 - Volume = (√2/3) * a³
  • surface_area_regular_octahedron(edge_length: m) -> m^2 - Surface area = 2√3 * a²
  • volume_regular_icosahedron(edge_length: m) -> m^3 - Volume = (5/12) * (3+√5) * a³
  • surface_area_regular_icosahedron(edge_length: m) -> m^2 - Surface area = 5√3 * a²
  • volume_regular_dodecahedron(edge_length: m) -> m^3 - Volume = (1/4) * (15+7√5) * a³
  • surface_area_regular_dodecahedron(edge_length: m) -> m^2 - Surface area = 3√(25+10√5) * a²
  • distance_2d(x1: m, y1: m, x2: m, y2: m) -> m - Distance between two points in 2D: √[(x₂-x₁)² + (y₂-y₁)²]
  • distance_3d(x1: m, y1: m, z1: m, x2: m, y2: m, z2: m) -> m - Distance between two points in 3D: √[(x₂-x₁)² + (y₂-y₁)² + (z₂-z₁)²]
  • midpoint_x_2d(x1: m, x2: m) -> m - X-coordinate of midpoint between two points in 2D
  • midpoint_y_2d(y1: m, y2: m) -> m - Y-coordinate of midpoint between two points in 2D
  • midpoint_x_3d(x1: m, x2: m) -> m - X-coordinate of midpoint between two points in 3D
  • midpoint_y_3d(y1: m, y2: m) -> m - Y-coordinate of midpoint between two points in 3D
  • midpoint_z_3d(z1: m, z2: m) -> m - Z-coordinate of midpoint between two points in 3D

Rhombus Functions

  • area_rhombus(diagonal1: m, diagonal2: m) -> m^2
  • area_rhombus_side_height(side: m, height: m) -> m^2
  • perimeter_rhombus(side: m) -> m

Sphere Functions

  • volume_sphere(radius: m) -> m^3
  • surface_area_sphere(radius: m) -> m^2

Torus Functions

  • volume_torus(major_radius: m, minor_radius: m) -> m^3
  • surface_area_torus(major_radius: m, minor_radius: m) -> m^2

Trapezoid Functions

  • area_trapezoid(base1: m, base2: m, height: m) -> m^2

Triangle Functions

  • area_triangle(base: m, height: m) -> m^2
  • area_triangle_heron(a: m, b: m, c: m) -> m^2

kinematics

Kinematics Functions

Motion equations for velocity, acceleration, displacement, and projectile motion

Acceleration Functions

  • acceleration_velocity_time(initial_velocity: m/s, final_velocity: m/s, time: s) -> m/s^2 - Average acceleration: a = Δv/t
  • acceleration_force_mass(force: N, mass: kg) -> m/s^2 - Acceleration from force: a = F/m

Circular Motion Functions

  • angular_velocity_linear(linear_velocity: m/s, radius: m) -> Hz - Angular velocity from linear velocity: ω = v/r (returns Hz = 1/s)
  • angular_velocity_period(period: s) -> Hz - Angular velocity from period: ω = 2π/T (returns Hz = 1/s)
  • angular_velocity_frequency(frequency: Hz) -> Hz - Angular velocity from frequency: ω = 2πf (returns Hz = 1/s)
  • linear_velocity_angular(angular_velocity: Hz, radius: m) -> m/s - Linear velocity from angular velocity: v = ωr (angular_velocity in Hz = 1/s)
  • centripetal_acceleration(velocity: m/s, radius: m) -> m/s^2 - Centripetal acceleration: a = v²/r
  • centripetal_acceleration_angular(angular_velocity: Hz, radius: m) -> m/s^2 - Centripetal acceleration using angular velocity: a = ω²r (angular_velocity in Hz = 1/s)
  • period_frequency(frequency: Hz) -> s - Period from frequency: T = 1/f
  • frequency_period(period: s) -> Hz - Frequency from period: f = 1/T

Displacement Functions

  • displacement_velocity_time(initial_velocity: m/s, final_velocity: m/s, time: s) -> m - Displacement from average velocity: Δx = (v₀ + v)t/2
  • displacement_initial_acceleration_time(initial_velocity: m/s, acceleration: m/s^2, time: s) -> m - Displacement: Δx = v₀t + (1/2)at²
  • displacement_velocity_acceleration(initial_velocity: m/s, final_velocity: m/s, acceleration: m/s^2) -> m - Displacement: Δx = (v² - v₀²)/(2a)

Free Fall Functions

  • free_fall_velocity(initial_velocity: m/s, time: s) -> m/s - Velocity in free fall: v = v₀ + gt (downward positive, uses standard gravity constant g)
  • free_fall_displacement(initial_velocity: m/s, time: s) -> m - Displacement in free fall: Δy = v₀t + (1/2)gt²
  • free_fall_time_max_height(initial_velocity: m/s) -> s - Time to reach maximum height: t = v₀/g
  • free_fall_max_height(initial_velocity: m/s) -> m - Maximum height: h = v₀²/(2g)

Projectile Motion Functions

  • projectile_range(initial_velocity: m/s, angle_radians: dimensionless) -> m - Horizontal range: R = (v₀² sin(2θ))/g
  • projectile_max_height(initial_velocity: m/s, angle_radians: dimensionless) -> m - Maximum height: h = (v₀² sin²(θ))/(2g)
  • projectile_time_of_flight(initial_velocity: m/s, angle_radians: dimensionless) -> s - Time of flight: t = (2v₀ sin(θ))/g
  • projectile_velocity_x(initial_velocity: m/s, angle_radians: dimensionless) -> m/s - Horizontal velocity component: vx = v₀ cos(θ)
  • projectile_velocity_y(initial_velocity: m/s, angle_radians: dimensionless, time: s) -> m/s - Vertical velocity component: vy = v₀ sin(θ) - gt
  • projectile_position_x(initial_velocity: m/s, angle_radians: dimensionless, time: s) -> m - Horizontal position: x = v₀ cos(θ) t
  • projectile_position_y(initial_velocity: m/s, angle_radians: dimensionless, time: s) -> m - Vertical position: y = v₀ sin(θ) t - (1/2)gt²

Relative Motion Functions

  • relative_velocity(velocity1: m/s, velocity2: m/s) -> m/s - Relative velocity: v_rel = v1 - v2
  • velocity_addition_1d(velocity1: m/s, velocity2: m/s) -> m/s - Velocity addition in 1D: v_total = v1 + v2

Velocity Functions

  • velocity_displacement_time(displacement: m, time: s) -> m/s - Average velocity: v = Δx/t
  • velocity_initial_acceleration_time(initial_velocity: m/s, acceleration: m/s^2, time: s) -> m/s - Final velocity: v = v₀ + at
  • velocity_initial_acceleration_displacement(initial_velocity: m/s, acceleration: m/s^2, displacement: m) -> m/s - Final velocity from displacement: v² = v₀² + 2aΔx

mechanics

Mechanics Functions

Force, work, energy, power, momentum, and torque calculations

Collision Functions

  • momentum_conservation_1d(mass1: kg, velocity1_initial: m/s, mass2: kg, velocity2_initial: m/s, velocity1_final: m/s) -> m/s - Conservation of momentum in 1D: m1v1i + m2v2i = m1v1f + m2v2f
  • kinetic_energy_elastic_collision(mass1: kg, velocity1_initial: m/s, mass2: kg, velocity2_initial: m/s) -> J - Total kinetic energy before collision (for elastic collision calculations)

Efficiency Functions

  • efficiency_useful_output(useful_output: J, total_input: J) -> dimensionless - Efficiency: η = (useful output / total input) * 100%
  • efficiency_power(useful_power: W, total_power: W) -> dimensionless - Efficiency from power: η = (useful power / total power)

Energy Functions

  • energy_kinetic(mass: kg, velocity: m/s) -> J - Kinetic energy: KE = (1/2)mv²
  • energy_potential_gravitational(mass: kg, height: m) -> J - Gravitational potential energy: PE = mgh
  • energy_potential_spring(spring_constant: N/m, displacement: m) -> J - Spring potential energy: PE = (1/2)kx²
  • energy_mechanical(kinetic_energy: J, potential_energy: J) -> J - Total mechanical energy: E = KE + PE

Force Functions

  • force(mass: kg, acceleration: m/s^2) -> N - Newton's second law: F = ma
  • force_weight(mass: kg) -> N - Weight force: F = mg
  • force_friction_kinetic(normal_force: N, coefficient_kinetic: dimensionless) -> N - Kinetic friction: F = μk * N
  • force_friction_static_max(normal_force: N, coefficient_static: dimensionless) -> N - Maximum static friction: F = μs * N
  • force_centripetal(mass: kg, velocity: m/s, radius: m) -> N - Centripetal force: F = mv²/r
  • force_centripetal_angular(mass: kg, angular_velocity: Hz, radius: m) -> N - Centripetal force using angular velocity: F = mω²r (angular_velocity in Hz = 1/s)
  • force_gravitational(mass1: kg, mass2: kg, distance: m) -> N - Newton's law of universal gravitation: F = G * m1 * m2 / r²

Momentum Functions

  • momentum(mass: kg, velocity: m/s) -> kg*m/s - Linear momentum: p = mv
  • momentum_change(initial_momentum: kg*m/s, final_momentum: kg*m/s) -> kg*m/s - Change in momentum: Δp = pf - pi
  • impulse(force: N, time: s) -> kg*m/s - Impulse: J = Ft
  • impulse_momentum_theorem(initial_momentum: kg*m/s, final_momentum: kg*m/s) -> kg*m/s - Impulse-momentum theorem: J = Δp

Power Functions

  • power_work_time(work: J, time: s) -> W - Power: P = W/t
  • power_force_velocity(force: N, velocity: m/s) -> W - Power: P = Fv (force parallel to velocity)
  • power_force_velocity_angle(force: N, velocity: m/s, angle_radians: dimensionless) -> W - Power with force at angle: P = Fv cos(θ)

Pressure Functions

  • pressure_force_area(force: N, area: m^2) -> Pa - Pressure: P = F/A
  • pressure_depth(density: kg/m^3, depth: m) -> Pa - Hydrostatic pressure: P = ρgh

Spring Functions

  • spring_force(spring_constant: N/m, displacement: m) -> N - Hooke's law: F = -kx (returns magnitude, sign indicates direction)
  • spring_constant(force: N, displacement: m) -> N/m - Spring constant from force and displacement: k = F/x

Torque Functions

  • torque_force_radius(force: N, radius: m) -> N*m - Torque: τ = Fr (force perpendicular to radius)
  • torque_force_radius_angle(force: N, radius: m, angle_radians: dimensionless) -> N*m - Torque with force at angle: τ = Fr sin(θ)
  • torque_angular_acceleration(moment_of_inertia: kg*m^2, angular_acceleration: Hz/s) -> N*m - Rotational form of Newton's second law: τ = Iα (angular_acceleration in Hz/s = 1/s^2)

Work Functions

  • work_force_distance(force: N, distance: m) -> J - Work done by constant force: W = Fd (force parallel to displacement)
  • work_force_distance_angle(force: N, distance: m, angle_radians: dimensionless) -> J - Work done by force at angle: W = Fd cos(θ)

thermo

Thermodynamics Functions

  • heat_specific_heat(mass: kg, specific_heat: J/(kg*K), temperature_change: K) -> J - Heat transfer: Q = mcΔT
  • heat_heat_capacity(heat_capacity: J/K, temperature_change: K) -> J
  • heat_latent(mass: kg, latent_heat: J/kg) -> J
  • heat_fusion(mass: kg, latent_heat_fusion: J/kg) -> J - Heat of fusion: Q = mLf
  • heat_vaporization(mass: kg, latent_heat_vaporization: J/kg) -> J - Heat of vaporization: Q = mLv
  • specific_heat_from_heat(mass: kg, heat: J, temperature_change: K) -> J/(kg*K) - Specific heat: c = Q/(mΔT)
  • heat_capacity_from_heat(heat: J, temperature_change: K) -> J/K - Heat capacity: C = Q/ΔT
  • heat_capacity_from_specific_heat(mass: kg, specific_heat: J/(kg*K)) -> J/K - Heat capacity: C = mc
  • specific_heat_from_heat_capacity(mass: kg, heat_capacity: J/K) -> J/(kg*K) - Specific heat: c = C/m
  • thermal_expansion_linear(length: m, coefficient_linear: 1/K, temperature_change: K) -> m - Linear thermal expansion: ΔL = αL₀ΔT
  • thermal_expansion_linear_final(length_initial: m, coefficient_linear: 1/K, temperature_change: K) -> m - Final length after linear expansion: L = L₀(1 + αΔT)
  • thermal_expansion_area(area: m^2, coefficient_linear: 1/K, temperature_change: K) -> m^2 - Area thermal expansion: ΔA ≈ 2αA₀ΔT (for small expansions)
  • thermal_expansion_volume(volume: m^3, coefficient_linear: 1/K, temperature_change: K) -> m^3 - Volume thermal expansion: ΔV ≈ 3αV₀ΔT (for small expansions)
  • thermal_expansion_volume_final(volume_initial: m^3, coefficient_volume: 1/K, temperature_change: K) -> m^3
  • heat_conduction(thermal_conductivity: W/(m*K), area: m^2, temperature_difference: K, thickness: m) -> W - Conduction heat transfer rate: Q/t = kAΔT/d
  • heat_conduction_energy(thermal_conductivity: W/(m*K), area: m^2, temperature_difference: K, thickness: m, time: s) -> J - Conduction heat transfer: Q = (kAΔT/d) * t
  • heat_convection(convection_coefficient: W/(m^2*K), area: m^2, temperature_difference: K) -> W - Convection heat transfer rate: Q/t = hAΔT
  • heat_convection_energy(convection_coefficient: W/(m^2*K), area: m^2, temperature_difference: K, time: s) -> J - Convection heat transfer: Q = hAΔT * t
  • heat_radiation(emissivity: dimensionless, area: m^2, temperature: K) -> W - Radiation heat transfer rate: Q/t = εσAT⁴
  • heat_radiation_energy(emissivity: dimensionless, area: m^2, temperature: K, time: s) -> J - Radiation heat transfer: Q = εσAT⁴ * t
  • heat_radiation_net(emissivity: dimensionless, area: m^2, temperature_hot: K, temperature_cold: K) -> W - Net radiation heat transfer: Q/t = εσA(Tₕ⁴ - Tᶜ⁴)
  • work_isobaric(pressure: Pa, volume_change: m^3) -> J - Work in isobaric (constant pressure) process: W = PΔV
  • work_isothermal(pressure_initial: Pa, volume_initial: m^3, volume_final: m^3) -> J - Work in isothermal (constant temperature) process: W = P₁V₁ ln(V₂/V₁)
  • work_adiabatic(pressure_initial: Pa, volume_initial: m^3, volume_final: m^3, gamma: dimensionless) -> J
  • pressure_adiabatic(pressure_initial: Pa, volume_initial: m^3, volume_final: m^3, gamma: dimensionless) -> Pa - Pressure in adiabatic process: P₂ = P₁(V₁/V₂)^γ
  • temperature_adiabatic(temperature_initial: K, volume_initial: m^3, volume_final: m^3, gamma: dimensionless) -> K - Temperature in adiabatic process: T₂ = T₁(V₁/V₂)^(γ-1)
  • temperature_adiabatic_pressure(temperature_initial: K, pressure_initial: Pa, pressure_final: Pa, gamma: dimensionless) -> K - Temperature in adiabatic process: T₂ = T₁(P₂/P₁)^((γ-1)/γ)
  • efficiency_carnot(temperature_hot: K, temperature_cold: K) -> dimensionless - Carnot efficiency: η = 1 - Tᶜ/Tₕ
  • efficiency_thermal(work_output: J, heat_input: J) -> dimensionless - Thermal efficiency: η = W/Qₕ
  • efficiency_thermal_power(power_output: W, heat_input_rate: W) -> dimensionless - Thermal efficiency from power: η = P_out/P_in
  • coefficient_performance_cooling(heat_removed: J, work_input: J) -> dimensionless - Coefficient of performance (cooling): COP = Qᶜ/W
  • coefficient_performance_heating(heat_delivered: J, work_input: J) -> dimensionless - Coefficient of performance (heating): COP = Qₕ/W
  • entropy_change_heat(temperature: K, heat: J) -> J/K - Entropy change: ΔS = Q/T (for reversible process)
  • entropy_change_isothermal(heat: J, temperature: K) -> J/K - Entropy change in isothermal process: ΔS = Q/T
  • entropy_change_constant_volume(mass: kg, specific_heat_volume: J/(kg*K), temperature_initial: K, temperature_final: K) -> J/K - Entropy change at constant volume: ΔS = mCv ln(T₂/T₁)
  • entropy_change_constant_pressure(mass: kg, specific_heat_pressure: J/(kg*K), temperature_initial: K, temperature_final: K) -> J/K - Entropy change at constant pressure: ΔS = mCp ln(T₂/T₁)
  • enthalpy_change_constant_pressure(heat: J) -> J - Enthalpy change at constant pressure: ΔH = Q
  • enthalpy_change_ideal_gas(mass: kg, specific_heat_pressure: J/(kg*K), temperature_change: K) -> J - Enthalpy change for ideal gas: ΔH = mCpΔT
  • rms_velocity_ideal_gas(temperature: K, molar_mass: kg/mol) -> m/s - Root mean square velocity: v_rms = √(3RT/M)
  • average_kinetic_energy_ideal_gas(temperature: K) -> J - Average kinetic energy per molecule: KE_avg = (3/2)kT
  • internal_energy_ideal_gas_monatomic(moles: mol, temperature: K) -> J - Internal energy for monatomic ideal gas: U = (3/2)nRT
  • internal_energy_ideal_gas_diatomic(moles: mol, temperature: K) -> J - Internal energy for diatomic ideal gas: U = (5/2)nRT
  • internal_energy_ideal_gas_polyatomic(moles: mol, temperature: K, degrees_freedom: dimensionless) -> J