ExprUA Editor

Standard Library

Pre-built functions for common scientific and engineering calculations with unit-aware dimensional consistency

Usage

Stdlib modules are embedded in the binary at compile time and can be imported using the standard import syntax. Stdlib modules have priority over user modules with the same name, ensuring consistent behavior across all ExprUA programs.

# Import a module
import geometry
area = area_circle(5 m)  # Returns 78.53981633974483 m^2

# Import multiple modules
import geometry
import mechanics
import kinematics

# Use functions from imported modules
radius = 10 m
volume = volume_sphere(radius)
force = force(5 kg, 9.81 m/s²)

geometry

Geometric Functions

Calculate areas, volumes, and perimeters for common 2D and 3D shapes with unit-aware dimensional consistency.

Circle Functions

  • area_circle(radius: m) -> m^2 - Area of a circle
  • circumference_circle(radius: m) -> m - Circumference of a circle
  • area_circle_sector(radius: m, angle_radians: dimensionless) -> m^2 - Area of a circle sector
  • arc_length_circle_sector(radius: m, angle_radians: dimensionless) -> m - Arc length of a circle sector
  • area_circle_segment(radius: m, angle_radians: dimensionless) -> m^2 - Area of a circle segment
  • area_annulus(outer_radius: m, inner_radius: m) -> m^2 - Area of an annulus (ring)
  • perimeter_annulus(outer_radius: m, inner_radius: m) -> m - Perimeter of an annulus

Sphere Functions

  • volume_sphere(radius: m) -> m^3 - Volume of a sphere
  • surface_area_sphere(radius: m) -> m^2 - Surface area of a sphere

Cylinder Functions

  • volume_cylinder(radius: m, height: m) -> m^3 - Volume of a cylinder
  • surface_area_cylinder(radius: m, height: m) -> m^2 - Total surface area of a cylinder
  • lateral_surface_area_cylinder(radius: m, height: m) -> m^2 - Lateral surface area of a cylinder

Cone Functions

  • volume_cone(radius: m, height: m) -> m^3 - Volume of a cone
  • surface_area_cone(radius: m, height: m) -> m^2 - Total surface area of a cone
  • lateral_surface_area_cone(radius: m, height: m) -> m^2 - Lateral surface area of a cone

Rectangle and Square Functions

  • area_rectangle(length: m, width: m) -> m^2 - Area of a rectangle
  • perimeter_rectangle(length: m, width: m) -> m - Perimeter of a rectangle
  • area_square(side: m) -> m^2 - Area of a square
  • perimeter_square(side: m) -> m - Perimeter of a square

Rectangular Prism and Cube Functions

  • volume_rectangular_prism(length: m, width: m, height: m) -> m^3 - Volume of a rectangular prism
  • surface_area_rectangular_prism(length: m, width: m, height: m) -> m^2 - Surface area of a rectangular prism
  • volume_cube(side: m) -> m^3 - Volume of a cube
  • surface_area_cube(side: m) -> m^2 - Surface area of a cube

Triangle Functions

  • area_triangle(base: m, height: m) -> m^2 - Area using base and height
  • area_triangle_heron(a: m, b: m, c: m) -> m^2 - Area using Heron's formula

Other 2D Shapes

  • area_trapezoid(base1: m, base2: m, height: m) -> m^2 - Area of a trapezoid
  • area_parallelogram(base: m, height: m) -> m^2 - Area of a parallelogram
  • area_ellipse(semi_major_axis: m, semi_minor_axis: m) -> m^2 - Area of an ellipse
  • perimeter_ellipse(semi_major_axis: m, semi_minor_axis: m) -> m - Perimeter of an ellipse
  • area_rhombus(diagonal1: m, diagonal2: m) -> m^2 - Area of a rhombus
  • area_rhombus_side_height(side: m, height: m) -> m^2 - Area of a rhombus using side and height
  • perimeter_rhombus(side: m) -> m - Perimeter of a rhombus
  • area_kite(diagonal1: m, diagonal2: m) -> m^2 - Area of a kite

Regular Polygon Functions

  • area_regular_polygon(side_length: m, num_sides: dimensionless) -> m^2 - Area of a regular polygon
  • perimeter_regular_polygon(side_length: m, num_sides: dimensionless) -> m - Perimeter of a regular polygon
  • area_regular_hexagon(side: m) -> m^2 - Area of a regular hexagon
  • perimeter_regular_hexagon(side: m) -> m - Perimeter of a regular hexagon
  • area_regular_pentagon(side: m) -> m^2 - Area of a regular pentagon
  • perimeter_regular_pentagon(side: m) -> m - Perimeter of a regular pentagon

Pyramid Functions

  • volume_pyramid_square_base(base_side: m, height: m) -> m^3 - Volume of a square-based pyramid
  • volume_pyramid_rectangular_base(length: m, width: m, height: m) -> m^3 - Volume of a rectangular-based pyramid
  • surface_area_pyramid_square_base(base_side: m, height: m) -> m^2 - Surface area of a square-based pyramid

Other 3D Shapes

  • volume_torus(major_radius: m, minor_radius: m) -> m^3 - Volume of a torus
  • surface_area_torus(major_radius: m, minor_radius: m) -> m^2 - Surface area of a torus
  • volume_ellipsoid(semi_axis_a: m, semi_axis_b: m, semi_axis_c: m) -> m^3 - Volume of an ellipsoid

Regular Polyhedron Functions

  • volume_regular_tetrahedron(edge_length: m) -> m^3 - Volume of a regular tetrahedron
  • surface_area_regular_tetrahedron(edge_length: m) -> m^2 - Surface area of a regular tetrahedron
  • volume_regular_octahedron(edge_length: m) -> m^3 - Volume of a regular octahedron
  • surface_area_regular_octahedron(edge_length: m) -> m^2 - Surface area of a regular octahedron
  • volume_regular_icosahedron(edge_length: m) -> m^3 - Volume of a regular icosahedron
  • surface_area_regular_icosahedron(edge_length: m) -> m^2 - Surface area of a regular icosahedron
  • volume_regular_dodecahedron(edge_length: m) -> m^3 - Volume of a regular dodecahedron
  • surface_area_regular_dodecahedron(edge_length: m) -> m^2 - Surface area of a regular dodecahedron

Coordinate Geometry Functions

  • distance_2d(x1: m, y1: m, x2: m, y2: m) -> m - Distance between two points in 2D
  • distance_3d(x1: m, y1: m, z1: m, x2: m, y2: m, z2: m) -> m - Distance between two points in 3D
  • midpoint_2d(x1: m, y1: m, x2: m, y2: m) -> m - X-coordinate of midpoint in 2D
  • midpoint_3d(x1: m, y1: m, z1: m, x2: m, y2: m, z2: m) -> m - X-coordinate of midpoint in 3D

mechanics

Mechanics Functions

Calculate forces, work, energy, power, momentum, torque, and pressure with dimensional consistency.

Force Functions

  • force(mass: kg, acceleration: m/s^2) -> N - Newton's second law
  • force_weight(mass: kg) -> N - Weight force (uses standard gravity constant g)
  • force_friction_kinetic(normal_force: N, coefficient_kinetic: dimensionless) -> N - Kinetic friction force
  • force_friction_static_max(normal_force: N, coefficient_static: dimensionless) -> N - Maximum static friction force
  • force_centripetal(mass: kg, velocity: m/s, radius: m) -> N - Centripetal force
  • force_centripetal_angular(mass: kg, angular_velocity: Hz, radius: m) -> N - Centripetal force from angular velocity
  • force_gravitational(mass1: kg, mass2: kg, distance: m) -> N - Gravitational force (uses gravitational constant G)

Work Functions

  • work_force_distance(force: N, distance: m) -> J - Work done by constant force
  • work_force_distance_angle(force: N, distance: m, angle_radians: dimensionless) -> J - Work with angle component

Energy Functions

  • energy_kinetic(mass: kg, velocity: m/s) -> J - Kinetic energy
  • energy_potential_gravitational(mass: kg, height: m) -> J - Gravitational potential energy (uses standard gravity constant g)
  • energy_potential_spring(spring_constant: N/m, displacement: m) -> J - Spring potential energy
  • energy_mechanical(kinetic_energy: J, potential_energy: J) -> J - Total mechanical energy

Power Functions

  • power_work_time(work: J, time: s) -> W - Power from work and time
  • power_force_velocity(force: N, velocity: m/s) -> W - Power from force and velocity
  • power_force_velocity_angle(force: N, velocity: m/s, angle_radians: dimensionless) -> W - Power with angle component

Momentum Functions

  • momentum(mass: kg, velocity: m/s) -> kg*m/s - Linear momentum
  • momentum_change(initial_momentum: kg*m/s, final_momentum: kg*m/s) -> kg*m/s - Change in momentum
  • impulse(force: N, time: s) -> kg*m/s - Impulse
  • impulse_momentum_theorem(initial_momentum: kg*m/s, final_momentum: kg*m/s) -> kg*m/s - Impulse-momentum theorem

Torque Functions

  • torque_force_radius(force: N, radius: m) -> N*m - Torque from force and radius
  • torque_force_radius_angle(force: N, radius: m, angle_radians: dimensionless) -> N*m - Torque with angle component
  • torque_angular_acceleration(moment_of_inertia: kg*m^2, angular_acceleration: Hz/s) -> N*m - Torque from angular acceleration

Pressure Functions

  • pressure_force_area(force: N, area: m^2) -> Pa - Pressure from force and area
  • pressure_depth(density: kg/m^3, depth: m) -> Pa - Hydrostatic pressure (uses standard gravity constant g)

Spring Functions

  • spring_force(spring_constant: N/m, displacement: m) -> N - Spring force (Hooke's law)
  • spring_constant(force: N, displacement: m) -> N/m - Spring constant from force and displacement

Collision Functions

  • momentum_conservation_1d(mass1: kg, velocity1_initial: m/s, mass2: kg, velocity2_initial: m/s, velocity1_final: m/s) -> m/s - Final velocity of mass2 in 1D collision
  • kinetic_energy_elastic_collision(mass1: kg, velocity1_initial: m/s, mass2: kg, velocity2_initial: m/s) -> J - Total kinetic energy in elastic collision

Efficiency Functions

  • efficiency_useful_output(useful_output: J, total_input: J) -> dimensionless - Efficiency from energy
  • efficiency_power(useful_power: W, total_power: W) -> dimensionless - Efficiency from power

kinematics

Kinematics Functions

Calculate motion equations, velocity, acceleration, displacement, projectile motion, and circular motion.

Velocity Functions

  • velocity_displacement_time(displacement: m, time: s) -> m/s - Average velocity
  • velocity_initial_acceleration_time(initial_velocity: m/s, acceleration: m/s^2, time: s) -> m/s - Final velocity from acceleration
  • velocity_initial_acceleration_displacement(initial_velocity: m/s, acceleration: m/s^2, displacement: m) -> m/s - Final velocity from displacement

Acceleration Functions

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

Displacement Functions

  • displacement_velocity_time(initial_velocity: m/s, final_velocity: m/s, time: s) -> m - Displacement from average velocity
  • displacement_initial_acceleration_time(initial_velocity: m/s, acceleration: m/s^2, time: s) -> m - Displacement with constant acceleration
  • displacement_velocity_acceleration(initial_velocity: m/s, final_velocity: m/s, acceleration: m/s^2) -> m - Displacement from velocity and acceleration

Free Fall Functions

  • free_fall_velocity(initial_velocity: m/s, time: s) -> m/s - Velocity in free fall (uses standard gravity constant g)
  • free_fall_displacement(initial_velocity: m/s, time: s) -> m - Displacement in free fall (uses standard gravity constant g)
  • free_fall_time_max_height(initial_velocity: m/s) -> s - Time to reach maximum height (uses standard gravity constant g)
  • free_fall_max_height(initial_velocity: m/s) -> m - Maximum height in free fall (uses standard gravity constant g)

Projectile Motion Functions

  • projectile_range(initial_velocity: m/s, angle_radians: dimensionless) -> m - Horizontal range (uses standard gravity constant g)
  • projectile_max_height(initial_velocity: m/s, angle_radians: dimensionless) -> m - Maximum height (uses standard gravity constant g)
  • projectile_time_of_flight(initial_velocity: m/s, angle_radians: dimensionless) -> s - Time of flight (uses standard gravity constant g)
  • projectile_velocity_x(initial_velocity: m/s, angle_radians: dimensionless) -> m/s - Horizontal velocity component
  • projectile_velocity_y(initial_velocity: m/s, angle_radians: dimensionless, time: s) -> m/s - Vertical velocity component (uses standard gravity constant g)
  • projectile_position_x(initial_velocity: m/s, angle_radians: dimensionless, time: s) -> m - Horizontal position
  • projectile_position_y(initial_velocity: m/s, angle_radians: dimensionless, time: s) -> m - Vertical position (uses standard gravity constant g)

Circular Motion Functions

  • angular_velocity_linear(linear_velocity: m/s, radius: m) -> Hz - Angular velocity from linear velocity
  • angular_velocity_period(period: s) -> Hz - Angular velocity from period
  • angular_velocity_frequency(frequency: Hz) -> Hz - Angular velocity from frequency
  • linear_velocity_angular(angular_velocity: Hz, radius: m) -> m/s - Linear velocity from angular velocity
  • angular_acceleration(initial_angular_velocity: Hz, final_angular_velocity: Hz, time: s) -> 1/s² - Angular acceleration
  • centripetal_acceleration(velocity: m/s, radius: m) -> m/s^2 - Centripetal acceleration
  • centripetal_acceleration_angular(angular_velocity: Hz, radius: m) -> m/s^2 - Centripetal acceleration from angular velocity
  • period_frequency(frequency: Hz) -> s - Period from frequency
  • frequency_period(period: s) -> Hz - Frequency from period

Relative Motion Functions

  • relative_velocity(velocity1: m/s, velocity2: m/s) -> m/s - Relative velocity
  • velocity_addition_1d(velocity1: m/s, velocity2: m/s) -> m/s - Velocity addition in 1D