Center of Mass Calculator (Using Integration)


Center of Mass Calculator (Using Integration)

Calculate Center of Mass


Enter a valid JavaScript math expression, e.g., Math.sin(x) or x*x.


Defines the lower edge of the 2D region.


Use ‘1’ for uniform density (centroid). Can be a function of x, e.g., 2*x.


The left boundary of the region.


The right boundary of the region.

Invalid input. Please check your functions and intervals.

Center of Mass (Xcm, Ycm): (0.00, 2.00)

Total Mass (M): 21.33

Moment about y-axis (My): 0.00

Moment about x-axis (Mx): 42.67

Calculated via numerical integration: Xcm = My / M, Ycm = Mx / M

Visualization of the functions, region, and calculated Center of Mass (red dot).

What is the Center of Mass?

The center of mass is the unique point where the weighted relative position of the distributed mass sums to zero. In simpler terms, it’s the point at which an object can be perfectly balanced. For a system of discrete point masses, you can find it with a simple weighted average. However, for a continuous object like a flat plate (a lamina), you must calculate the center of mass using integration. This is a fundamental concept in physics and engineering, crucial for understanding the motion of objects and for stability analysis.

If an object has uniform density, its center of mass is the same as its geometric center, which is called the centroid. This calculator can find both; simply use a constant density (like 1) to calculate the centroid. If the density varies across the object, the center of mass will be shifted toward the denser regions.

Center of Mass Formula and Explanation

To find the center of mass (Xcm, Ycm) of a 2D planar region bounded above by f(x), below by g(x), from x=a to x=b, and with a density function ρ(x), we use the following integral formulas:

  1. Total Mass (M): The total mass is the integral of the density multiplied by the area of infinitesimally small vertical strips.

    M = ∫[a, b] ρ(x) * (f(x) - g(x)) dx
  2. Moment about the y-axis (My): This measures the tendency of the mass to rotate around the y-axis.

    My = ∫[a, b] x * ρ(x) * (f(x) - g(x)) dx
  3. Moment about the x-axis (Mx): This measures the tendency of the mass to rotate around the x-axis.

    Mx = ∫[a, b] (1/2) * ρ(x) * (f(x)² - g(x)²) dx

Once these three values are calculated, the coordinates of the center of mass are found by a simple division:

  • Xcm = My / M
  • Ycm = Mx / M

Our physics calculator uses numerical integration to solve these definite integrals.

Variables Table

Description of variables used in the center of mass formulas.
Variable Meaning Unit (Typical) Typical Range
f(x) Upper boundary function length (e.g., meters) Any mathematical function
g(x) Lower boundary function length (e.g., meters) Any mathematical function
ρ(x) Density function mass/length (e.g., kg/m) Positive values
a, b Integration interval length (e.g., meters) Real numbers, with a < b
M, My, Mx Mass and Moments mass, mass·length Calculated values
(Xcm, Ycm) Center of Mass Coordinates length (e.g., meters) Calculated coordinates

Practical Examples

Example 1: Uniform Semicircle

Let’s calculate the center of mass for a uniform semicircle of radius 4, centered at the origin.

  • Inputs:
    • Upper function f(x): Math.sqrt(16 - x*x)
    • Lower function g(x): 0
    • Density function ρ(x): 1 (uniform)
    • Interval: a = -4, b = 4
  • Results:
    • By symmetry, we expect Xcm = 0.
    • The Ycm for a semicircle is known to be 4r/(3π). For r=4, this is 16/(3π) ≈ 1.698.
    • Calculator Result: (0.00, 1.70), which matches the analytical solution.

Example 2: Non-uniform Triangle

Consider a triangular lamina bounded by y=x, y=0, from x=0 to x=3, with a density that increases with x, ρ(x) = x.

  • Inputs:
    • Upper function f(x): x
    • Lower function g(x): 0
    • Density function ρ(x): x
    • Interval: a = 0, b = 3
  • Results:
    • Since the mass is more concentrated to the right, we expect the center of mass to be shifted right compared to a uniform triangle.
    • Calculator Result: (2.25, 0.90)

For more examples, check out resources on physics keywords and their applications.

How to Use This Center of Mass Calculator

  1. Enter Functions: Type your upper boundary f(x), lower boundary g(x), and density ρ(x) into the respective fields. Use JavaScript’s Math object for functions like Math.sin(), Math.pow(), or Math.sqrt().
  2. Set Interval: Define the horizontal span of your object by entering the start (a) and end (b) points of your integration.
  3. Calculate: Click the “Calculate” button. The results for Total Mass, Moments, and the final Center of Mass coordinates will appear instantly.
  4. Interpret Results: The primary result (Xcm, Ycm) is the balance point of your object. The chart provides a visual confirmation, plotting your functions and marking the calculated center of mass with a red dot.

Key Factors That Affect Center of Mass

  • Geometry: The shape defined by f(x) and g(x) is the primary factor. A top-heavy shape will have a higher center of mass.
  • Density Distribution: If density is not uniform (e.g., ρ(x) = x²), the center of mass will be pulled towards the regions of higher density.
  • Symmetry: For objects with uniform density and a line of symmetry, the center of mass will always lie on that line.
  • Coordinate System: The numerical values of the center of mass coordinates depend entirely on where you place the origin (0,0).
  • Added or Subtracted Mass: Adding mass to one side of an object will shift the center of mass toward that side.
  • Integration Bounds: The interval [a, b] defines the object. Changing the bounds changes the object itself and therefore its center of mass.

You can learn more about physics formulas to better understand these relationships.

Frequently Asked Questions (FAQ)

What if my density is constant?

If density is constant, the center of mass is called the centroid. Simply enter `1` into the density function field to calculate the centroid.

How do I enter functions like x²?

You must use valid JavaScript syntax. For powers, use x*x for x² or Math.pow(x, 2). Multiplication requires the * operator (e.g., 4*x, not 4x).

Why is the center of mass sometimes outside the object?

For concave or ring-shaped objects (like a doughnut or a boomerang), the balance point can be in empty space.

What is the difference between center of mass and centroid?

The centroid is the geometric center, assuming uniform density. The center of mass is the balance point, which accounts for variable density. They are the same only when density is uniform.

How accurate is this numerical integration?

This calculator uses a numerical method (the Trapezoidal Rule with a high number of slices) to approximate the integrals. It is highly accurate for most smooth functions but may have small errors for functions with sharp corners or discontinuities.

What units should I use?

The units of the output will match the units you use for the input. If your functions and intervals are in meters, the center of mass will be in meters. The key is to be consistent.

Can this calculator handle 3D objects?

No, this tool is specifically designed to calculate the center of mass using integration for 2D planar objects defined in an x-y coordinate system.

What does a ‘NaN’ result mean?

‘NaN’ (Not a Number) typically occurs if there’s a mathematical error, such as division by zero (if total mass is zero) or taking the square root of a negative number in one of your functions.

© 2026 Physics Tools Inc. All Rights Reserved.



Leave a Reply

Your email address will not be published. Required fields are marked *