# Formulas

This is an idea that I had a while back. I want to create a Java library of formulas and release it under a free license. There is currently a similar library available which is called JScience but it has somewhat restrictive usage terms.

Although this post is just an idea placeholder I want to place down a few guidelines that the library will adhere by.
1. There will be an emphasis on calculations: This means that this library will contain very few (if any) constants. My goal is to be able to calculate everything from the mass of a proton to the speed of light.
2. Flexible: The library might have the ability to convert units of measurement that normally wouldn't be able to be converted. An example of this might be something like lumens to candle power.

Common formulas for different things:

The formula to calculate the speed of an object:
speed = distance ÷ time

The formula to calculate the velocity of an object:
velocity = distance ÷ time, direction

The formula to calculate the dencity of an object:
density = mass ÷ volume

The formula to calculate the area of a parallelogram:
area = bace × height

The formula to calculate the area of a triangle:
area = ½ bace × height

The formula to calculate the area of a trapezoid:
area = ½ height (bace one + bace two)

The first formula to calculate the circumference of a circle:
circumference = pi × diamiter

The second formula to calculate the circumference of a circle:
circumference = 2 × pi × radius

The formula to calculate the area of a circle:

The formula to calculate the total surface area of rectangular prisms:
surface area = (length of front × width of front) + (length of back × width of back) + (length of top × width of top) + (length of bottom × width of bottom) + (length of side one × width of side one) + (length of side two × width of side two)

The formula to calculate the total surface area of a cylinder:
2 × pi × radius × 2 + 2 × pi × radius × height

The formula to calculate the volume of a rectangular prism:
volume = length × width × height

The formula to calculate the volume of a triangular prism:
volume = area of base × height

The formula to calculate the volume of a cylinder:
volume = area of base × height

The formula to calculate the volume of a cube:
volume = length × width × height

The formula to find the perimeter of a square:
perimeter = 4 × length

The formula to find the perimeter of a rectangle:
perimeter = 2 × base + 2 × height

The formula to find the perimeter of a triangle:
perimeter = side a + side b + side c

The formula to find the area of a square:
area = side × side

The formula to find the area of a rectangle:
area = length of base × width of side

COMPOSITION:
This table is an average for clean, dry air at sea level.
1 part/million = 0.0001 percent
Content=% of volume

Nitrogen (N2)=78.084 percent > 99.998%
Oxygen (O2)=20.947 percent > 99.998%
Argon (Ar)=0.934 percent > 99.998%
Carbon dioxide (CO2)=0.033 percent > 99.998%
Neon (Ne)=18.2 parts/million
Helium (He)=5.2 parts/million
Krypton (Kr)=1.1 parts/million
Sulfur dioxide (SO2)=1.0 parts/million
Methane (CH4)=2.0 parts/million
Hydrogen (H2)=0.5 parts/million
Nitrous oxide (N2O)=0.5 parts/million
Xenon (Xe)=0.09 parts/million
Ozone (O3)=0.0 to 0.07 parts/million
Ozone - Winter (O3)=0.0 to 0.02 parts/million
Nitrogen dioxide (NO2)=0.02 parts/million
Iodine (I2)=0.01 parts/million
Carbon monoxide (CO)=0.0 to trace
Ammonia (NH3)=0.0 to trace

PROPERTIES:
density of air at standard temperature and pressure: 1.2929 kilograms/cu meter = 0.0807 pounds/cu foot
Universal Gas Constant (R): 0.0821 liter-atmosphere/degrees kelvin/mole
Standard Temperature & Pressure (STP): Standard Temperature = 0° Celsius = 32° Fahrenheit = 273.15° Kelvin
Standard Pressure = 760 mm Hg = 14.70 pounds per square inch = 2116.22 pounds per square foot = 29.92 inch Hg = 1.01325 × 100000 N/m
Speed of sound in dry air at STP: 331.4 meters per second = 742.5 miles per hour
ICAO Sea Level Air Standard Values: Atmospheric pressure = 760 mm Hg = 14.7 lbs per square inch, Temperature = 15° Celsius = 288.15° Kelvin = 59° Fahrenheit

WEIGHTS OF GASES:
Air = 1.2928 = 0.08071
Air at 59° Fahrenheit = 1.2256 = 0.07651
Argon = 1.7840 = 0.111368
Carbon Dioxide = 1.9770 = 0.123416
Carbon Monoxide = 1.2500 = 0.078033
Helium = 0.1785 = 0.011143
Hydrogen = 0.0899 = 0.005612
Neon = 0.9002 = 0.056196
Nitrogen = 1.2506 = 0.075261
Oxygen = 1.4290 = 0.089207
all weights listed above assume a dry gas at standard temperature and pressure (0° Celsius and 760 mm Hg)

STANDARD ATMOSPHERE:
The unit "1 Standard Atmosphere" is defined as the pressure equivalent to thar exerted by a 76 mm column of mercury at 0° Celsius (32° Fahrenheit), at sea level, and at standard gravity (32.174 feet/second squared). Atmospheric presure is simply the weight of a column of air per area unit as measured from the top of the atmosphere to the reference point being measured. Atmospheric pressure dacreases as altitude increases. Equivalents to 1 atmosphere are as follows:
76 centimeters of mercury
29.921 inches of mercury
10.3326 meters of water
406.788 inches of water
14.696 pounds per square inch
2,116.2 pounds per square foot

Perfect Gas Law:
PV = nRT
P=Pressure in atmosphere
V=Volume in liters n=number of moles
R=Gas constant (0.0821 liter-atmospheres/°K/mole)
T= Temperature in degrees K
if constant pressure: V1/V2 = T1/T2
if constant temperature: P1/P2 = V2/V1
if constant volume: P1/P2 = T1/T2

Boyle's Law
If temperature is kept constant, the volume of a given mass of gas is inversely proportional to the pressure which is exerted upon it.
Initial pressure ÷ Initial volume = Pressure change ÷ Final temperature °K

Dalton's Law of Partial Pressures
The pressure which is exerted on the walls of a vessel is the sum of the pressures which each gas would exert if it were present alone.

Graham's Law of Diffusion
Relative rates of diffusion of two gases are inversely proportional to the square roots of their densities.

Equal volumes of gases  measured under the same conditions of temperature and pressure, contain equal numbers of molecules.

Air Velocity in a Pipe:
V = v25,000 DP ÷ L
V=Air velocity in feet per second
D=Pipe inside diameter in inches
L=Length of pipe in feet
P=Pressure loss due to air friction in ounces/square inch
Approximate values of P are as follows:

Velocity Pipe diameter in inches, 10 feet long
feet/second 1 2 4 6 10

1 0.004 0.0002 0.0001 0.00006 0.00004
2 0.0016 0.0008 0.0004 0.0002 0.00016
5 0.0100 0.005 0.0025 0.0016 0.001
10 0.04 0.02 0.01 0.0066 0.004
15 ` 0.09 0.45 0.0225 0.015 0.0089
20 0.16 0.08 0.04 0.026 0.016
25 0.25 0.125 0.0625 0.041 0.025
30 0.36 0.18 0.09 0.06 0.036

Air Volume Discharge from Pipe:
CFM = 60VA
CFM=Air volume in feet per minute
V=Air velocity in feet per second as determined in the equation V = v25,000 DP ÷ L
A=Cross section area of pipe in square feet

Theoretical Horsepower to Compress Air:
HP = CFM × PSI × 0.0007575
HP = Compressor Horsepower
CFM = Airflow in cubic feet per minute
PSI=Air pressure in pounds per square inch
(assumes Atmospheric Pressure = 14.7 psi, Temperature = 60°F)