Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 22, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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.141592653589
Dim CapVolume As Single
Dim SphereRadius As Single
Dim CapHeight As Single
'Sample values
SphereRadius = 9.35
CapHeight = 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) / 3
CapVolume = PI * CapHeight * CapHeight _
	* (3 * SphereRadius - CapHeight) / 3
'Reality check
Debug.Print CapVolume
Stan Mlynek
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date