devxlogo

Entering Scientific Formulas

Entering Scientific Formulas

I have developed this technique to use when I program long formulas. First, I declare descriptive variables for the mathematical elements. I prototype the formula using the digit “1” as a place holder for the variables. This allows me to review the structure of the formula and make sure it compiles. I keep a copy of the formula as an inline comment.I replace the place holders with the variable by using cut and paste. This is an example that calculates the volume of a cap of a sphere:

 Public Const PI = 3.141592653589Dim CapVolume As SingleDim SphereRadius As SingleDim CapHeight As Single'Sample valuesSphereRadius = 9.35CapHeight = 3.33'Formula as prototype which is left in 'the code for the volume of the cap of a sphere'CapVolume = PI * 1 * 1 * (3 * 1 - 1) / 3CapVolume = PI * CapHeight * CapHeight _	* (3 * SphereRadius - CapHeight) / 3'Reality checkDebug.Print CapVolume
See also  11 Effective Keyword Research Tools and Techniques
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist