Expression Evaluator with Unit Handler Functions

*MJ@AnalysisChamp.com 4/29/2009 - 1/21/2023*

AnalysisChamp.com Complex Unit Converter

AnalysisChamp.com Home

Calculate expressions with units properly handled. Enter the expression value as a formula and input units as a formula. Also enter the desired output units. The expression evaluator will calculate the value, define the conversion factors for the units and verify that the desired output units are proper.

This site can process all MS VBScript functions. See
Microsoft MSDN VBScript Reference and
Microsoft Derived Functions
for specific information.
The names for all units are provided in
AnalysisChamp.com/EEx/AllUnitNames.htm and a shorter list of
more common unit names is located in
AnalysisChamp.com/EEx/FavUnitNames.htm.

Note: Apple Users may find that the double quotes required for string entry cause errors. This is because they do not alway us the ASCII standard chr(34) but instead use others that provide left and right distinctions. A function is provided to obtain proper quotes by selecting [parenthesis & quotes ...] just below the expression entry text box.

Expression Evaluator - Example Strings (See also: FreeStyle.xlsm)

MJ@AnalysisChamp.com

4/28/2009 - 1/21/23

Examples are given using short function callout versions

(turn word wrap off before copying strings and pasting into expression evaluator)

Each expression string can be copied from the web page by selecting the text and pressing ctrl^C then inserting into the evaluation field and pressing ctrl^V.

The precision of returned values is not more accurate than 6 significant digits.

__Example 00 - Enter parenthese and/or double quotes for Calculations__

-[Parentheses & Quotes]-[Enter Example 00]

Some devices do not have the "double quote" in their keyboards and this will bring them to the a text box for use by copy-paste in any function or expression.

------

*sc(.) *

__Example 01 - Temperature Calculations__

[Enter Example 01]

What is the absolute temperature, degrees Kelvin, at 32 degrees farenheight (F)?

------

*cv(32,"DEGF","DEGK") *

= 273.15

__Example 02.01 - Length Conversions __

[Enter Example 02.01]

What is the length, in feet, of 200 rods?

------

*cv(200,"ROD","FT") *

= 3300 ft

__Example 02.02 - Circle Perimeter __

[Enter Example 02.02]

What is the length, in feet, of the perimeter of a circle 12 inches in diameter?

------

*cv(12,"PI*IN","FT") *

= 3.1415863 ft

__Example 02.03 - Circle Area __

[Enter Example 02.03]

What is the area, in square feet, of a circle whose diameter is 24 inches?

------

*cv(1/4*24^2,"PI*IN^2","FT^2") *

= 3.1415863 ft^2

__Example 03 - Speed, Torque and Power Calculations __

[Enter Example 03]

What is the torque, in pound-feet, of a shaft driving a 10 horsepower load at 3600 revolutions per minute?

Power = torque * speed so torque = power / speed

------

*cv(10/3600,"HP/RPM","FT*LBF") *

= 14.6 ft*lbf

__Example 04 - Gas Law Calculations __

[Enter Example 04A]
[Enter Example 04B]

[Enter Example 04C]

What is the volume per mole of an ideal gas (like air) at 0 degC (273.15 degK) and atmoshperic pressure?

p*V = n*R*T so V/n = R*T/p

------

Two methods may be used. Temperature is a biased measurement unit. In this case, if the temperature in degrees Centigrade was used directly it would give erroneous results. First, convert temperature into DEGK...

** cv(0,"DEGC","DEGK")** = 273.15, then:

= 22.4 L/Mole

A second approach involves inserting Base Unit conversion functions into the analysis string...

= 22.4 L/Mole

... The temperature is properly calculated with this approach in a single expression.

What is the density of air, in pounds per cubic foot, at 15 degC (288 degK) and

atmospheric pressure of 30.10 inches-mercury?

[Enter Example 05]

p*V = n*R*T and mass = moles * grams per mole (gpm) so n/V = p/(R*T) and density = n*gpm/V = p * gpm / (R*T)

------

As in example 4, the temperature needs to be in an absolute measurement system for proper evaluation...

= .0763 lbm/ft^3

Alternatevly, the use of Base Value functions inserted into the expression string provides proper results...

= .0763 lbm/ft^3

What is the tip speed, mach at standard sea level atmosphere, of a 72 inch diameter propeller spinning at 2400 RPM?

[Enter Example 06]

V = diameter / 2 * rotational speed

------

= .675 mach

What is the hydraulic pressure of a 200 horsepower system with 400 gallons per minute flow rate?

[Enter Example 07]

power = pressure * flow rate so pressure = power / flow rate

------

= 857 psi

What is the dynamic pressure, in pascals, of an air-stream at 150 knots? Air density is .0775 pounds per cubic foot.

[Enter Example 08]

q = 1/2 * rho * V^2

------

= 3696 Pa

What is the side load on a shaft, in Newtons, with a 200 cm diameter sheave if it carries 30 kW power at 55 Hz?

[Enter Example 09]

F = p/(n*r)

------

= 86.8 Newton

What is the ideal radiated power per unit area of a body at 3000 degrees R in watts?

[Enter Example 10]

q = sigma * T^4

------

The temperature is expressed in absolute units and can be used without a primary conversion (see Example 5):

= 4.38E5 W/M^2

How many pounds of caffeine does a 1.35 mole sample weigh? The chemical formula for caffeine is C8-H10-N4-O2.

[Enter Example 11.1]

The formula weight of caffeine is 8*12.01115 + 10*1.00797 + 4*14.0067 + 2*15.9994

------

Addition and subtraction of units must be done carefully because they cannot be mixed within a sum or difference calculation. Checks on the units for each term in such a calculation must be made.

= .578 lbm

How many pounds of caffeine does a 1.35 mole sample weigh? The chemical formula for caffeine is C8H10N4O2.

[Enter Example 11.2]

The formula weight of caffeine, using the "MolWt" function with lookup capability, is calculated.

------

No need to add units simplifies the calculation shown above.

= .578 lbm

What is the chemical formula weight of water [H2O]?

[Enter Example 11.3]

The molecular weight of water, using the "MolWt" function with lookup capability, is calculated.

------

The MolWt function takes any chemical formula, looks up the element weights and multiplies by the number in molecule, and returns the total weight.

= 18.01528 AMU

How many electron / proton pairs exist in water [H2O]?

[Enter Example 11.4]

Water, chemical formula H2O, consists of two hydrogen (atomic number =1) and one oxygen (atomic number = 8). This identifies that each element of the compound contributes that many proton-electron pairs. The quantity for the compound is found using the "MolNum" function, with lookup capability.

------

The MolNum function takes any chemical formula, looks up the element numbers and multiplies by the number in molecule, and returns the total number. This is equivalent to the number of proton - electron pairs in the molecule.

= 10 ITEMS

[Enter Example 12]

What is the area of a circle, in square feet, if it has a diameter of 2 meter?

Area = pi/4 * Diameter^2

= 33.8157 ft^2

What is the temperature, in degrees Farenheight, of 1 billion standard cubic feet of an ideal gas at one atmosphere pressure?

[Enter Example 13A]

Ideal gas law:

p*V = m * RGC * T; solving for T:

T = (m * RGC)/(p * V)

where:

T = temperature, m = quantity (billion standard cubic feet), RGC = universal gas constant, p = pressure and V = volume.

------

The temperature can be returned in biased units (DEGC or DEGF) because the result is converted after evaluation.

= 60 degF

The expression can be checked using the base units as follows:

[Enter Example 13B]

= 60 degF

What is the weight, in pico*grains, of a 1/4 inch long string of carbon atoms if each averages 1.5E-08 centimeters in diameter?

[Enter Example 14]

Carbon has an atomic weight of 12.01115 grams per mole.

total weight = total length * Weight/Atom * number of Atoms/length

where the weight/atom = formula weight / Avogadro's number

------

= .013 pico*grain

What is the percent composition of chlorine in FeCl3? Iron (Fe) weighs 55.847 grams per mole and chlorine (Cl) weighs 35.453 grams per mole based on atomic weight.

[Enter Example 15]

Molecule Weight = Fe*1+Cl*3 = (1*(55.847)+3*(35.453)) MOL*(GM/MOL)

Chlorine weight per molecule = (35.453)*3

Cl Percentage = (chlorine weight per molecule)/(molecule weight)

------

= 65.6 percent (centi)

What is the centrifugal force of a mass of 3.31 lbm rotating at 3000 revolutions per minute (rpm) at a radius of 18 inches?

[Enter Example 16]

Centrifugal Force = mass * radius * rotation speed ^ 2

------

= 15230 lbf

What is the interpolated estimate for y where y=f(x) at x=.20 when y1=2.5 at x1=0.10 and y2=7.5 at x2=0.30?

[Enter Example 17]

The linear interpolation formula is: y = (x-x1)*(y2-y1)/(x2-x1)+y1

------

= 5.0

How much energy (in watts) is transferred through a concrete wall 8 feet tall x 12 feet wide x 8 inches thick when the temperature difference is 25 degrees F? The coefficient of thermal conductivity for concrete is .5 BTU*ft/(hr*ft^2*degR)

[Enter Example 18]

Heat flow Rate = (Coefficient of Thermal Conductivity * Area * Temperature difference)/thickness

------

= 527.5 W

[Enter Example 19.01]

What is the future value of $200,000.00, if the annual interest rate is 6.5 % and the number of periods is 30 years?

FV = FVperPV(PV, Interest, Periods)

------

= 1,322,873.23

[Enter Example 19.02]

What is the Present worth of $200,000.00 at 30 years from now if the annual interest rate is 6.5 %?

PV = PVperFV(FV, Interest, Periods)

------

= 30,237.21

[Enter Example 19.03]

What is the periodic payment amount for a future value of $200,000.00 at 30 years from now if the annual interest rate is 6.5 %?

Amount = AmtperFV(FV, Interest, Periods)

------

= 2,315.49

[Enter Example 19.04]

What is the periodic payment amount for a Present worth of $200,000.00 for 30 years if the annual interest rate is 6.5 %?

Amount = AmtperPV(PV, Interest, Periods)

------

= 15,315.49

[Enter Example 19.05]

What is the Future value of periodic payments of $150.00 for 30 years if the annual interest rate is 6.5 %?

FV = FVperAmt(Amt, Interest, Periods)

------

= 12,956.23

[Enter Example 19.06]

What is the Present worth of future periodic payments of $150.00 for 30 years if the annual interest rate is 6.5 %?

PV = PVperAmt(Amt, Interest, Periods)

------

= 1,958.80

[Enter Example 19.07]

What is the Present worth of future Gradient payments increasing $25.00 per period for 30 years if the annual interest rate is 6.5 %? The initial (1st) payment is $0.00, the 2nd payment is $25.00, the 3rd payment is $50.00 and so on.

PV = PVperGrad(Grad, Interest, Periods)

------

= 3,278.11

[Enter Example 19.08]

What is the equivalent uniform periodic payment of a Gradient payment series that increases $25.00 per period for 30 years if the annual interest rate is 6.5 %? The initial (1st) gradient payment is $0.00, the 2nd payment is $25.00, the 3rd payment is $50.00 and so on.

Amt = AmtperGrad(Grad, Interest, Periods)

------

= 251.03

[Enter Example 19.09]

What is the return on investment (annual percent) for a property purchased 2009 at $155000 and sold 2017 for $253500? The sales cost is 10%.

ROI = GoalSeekVar(.90*253500,0.0,25.0,.01, _

"FVperPV(155000,var/100,(2017-2009))")

------

"FVperPV(155000,var/100,(2017-2009))")

= 4.96

[Enter Example 19.10]

ROI = ROI(PV, FV, Periods, iMin, iMax, iStep)

-------

= 4.96

[Enter Example 20.01]

What is the hexadecimal value of 255?

The VBScript "HEX()" function converts a decimal number into it's hexadecimal string. For further info on the HEX() function see MSDN HEX function reference

------

= FF

[Enter Example 20.02]

What is the decimal value of "AA" hex?

The VBScript "CLng()" function converts a hex string into it's decimal equivalent if preceeded by "&h". For further info on the CLng() function see MSDN CLNG function reference

------

= 170

[Enter Example 20.03]

What is the octal value of 125?

The VBScript "OCT()" function converts a decimal number into it's octal value. For further info on the OCT() function see MSDN OCT function reference

------

= 175

[Enter Example 20.04]

What is the decimal value of 175 octal?

The VBScript "CLng()" function converts an octal value into it's decimal equivalent if preceeded by "&o". For further info on the CLng() function see MSDN CLNG function reference

------

= 125

[Enter Example 20.05]

What is the ANSI character with value 65?

The VBScript "CHR()" function converts a string into it's value. For further info on the ASC() function see MSDN CHR function reference

------

= A

[Enter Example 20.06]

What is the value of ANSI character "A"?

The VBScript "ASC()" function converts a character string into it's ANSI value. For further info on the ASC() function see MSDN ASC function reference

------

= 65

[Enter Example 21]

What is the factorial of 6?

The "FACTORIAL()" function calculates this value. For further info on the FACTORIAL() function see Factorial function code reference

------

= 720

[Enter Example 22]

What is the base-10 log of 5.25?

The "LOG()" function calculates this value for natural logs. Base-10 logs are found by using the ratio of the natural log of the value to the natural log of the base (in this case, 10). For further info on the LOG() function see LOG function reference

------

= 0.720159303405957

[Enter Example 23]

What angle (in radians) allows the following function, "SIN(var)+1.5" to evaluate to 1.75?

The GoalSeekVar() function allows a user-defined function for the variable (="var") for given target, min, max and step values to be determined. GoalSeekVar(target, varMin, varMax, varStep, strFun) will substitute values from min to max by step until the function evaluates to the target value. It will return the variable value needed to evaluate the function to the target value. When var = 0.2527, SIN(var)+1.5 = target value = 1.75. The "EVAL(REPLACE(string,target,replacement))" function can be used to evaluate a user defined function.

------

= 0.2527

The database of unit names can be queried using the

------

= 45 This is the index for the first unit that contains "degree" in its description. This function can be nested inside the FactorData function to retrieve the full description:

= degrees

Function List: (The two character shortcut is listed and then the full named function is shown)

Calculates the parameter value for the given value and units expressed as the output units.

Calculates the sum value for the two given values with units expressed as the output unit.

Expresses the given units as SI units.

Evaluates the given parameter into SI units.

Returns the specific field and record from the unit converter bases factors database. Field 1 is the name, field 2 is the check value and field 3 is the description.

Returns the specific record number from the unit converter base factors database for a given name.

Returns a unique check value for a unit text string based on its base units. Proper unit conversions yield equal check values.

Returns the specific field and record from the unit converter factors database.

Returns the specific record number from the unit converter factors database for a given name.

Returns the next record number from the given start record of the unit converter factors database for a given text string within the given field.

Returns the angle as radians when entered as degrees.

Returns the angle as degrees when entered as radians.

Returns the area as sq units for DIAMETER entered.

Returns the factorial for INTEGER entered.

Returns the variable for function entered within limits by step.

Returns the effective interest rate for given present and future values over a time duration with min and max interest range and iterative step size.

Owner@AnalysisChamp.com 1/19/2010, 5/12/2011, 10/9/2022