About BhashaIndia | Contribute | SiteMap | Register | Sign in to Windows Live ID
  Developers Patrons
Hindi Tamil Kannada Gujarati Marathi Telugu Bengali Malayalam Punjabi Konkani Oriya Sanskrit Nepali
Home > Developers > KnowHow > UnicodeMaths > Mathsprogram Welcome Guest!

Mathematics as a Programming Language

  • Fortran made great steps in getting computers to understand
  • Java and C# accept Unicode variable names
  • C++ has preprocessor and operator overloading, but needs extensions to be really powerful
  • Use Unicode characters including math alphanumerics 
  • Use plain-text encoding of mathematical expressions
  • Can't use all mathematical expressions as code, but can go much further than current languages go
  • When to multiply? In abstract, multiplication is infinitely fast and precise, but not on a computer

There has been substantial discussion recently concerning what Unicode characters should be considered as potential program identifiers. Typical mathematical symbols available in computer programs have been shown. Java made an important step (copied by C#) in this direction by allowing Unicode variable names. The math alphanumerics allow this approach to go further with relatively little effort for compilers.

A key point is that the compiler should display the desired characters in both edit and debug windows. A preprocessor can translate MathML, for example, into C++, but it won't be able to make the debug windows use the math-oriented characters unless it can handle the underlying Unicode characters.

The advantages of using the Unicode plain text in computer programs are at least threefold:

1) many formulas in document files can be programmed simply by copying them into a program file and inserting appropriate multiplication dots. This dramatically reduces coding time and errors.

2) The use of the same notation in programs and the associated journal articles and books leads to an unprecedented level of self documentation.

3) In addition to providing useful tools for the present, these proposed initial steps should help us figure out how to accomplish the ultimate goal of teaching computers to understand and use arbitrary mathematical expressions.

void IHBMWM(void)
{
gammap = gamma*sqrt(1 + I2);
upsilon = cmplx(gamma+gamma1, Delta);
alphainc = alpha0*(1-(gamma*gamma*I2/gammap)/(gammap + upsilon));
if (!gamma1 && fabs(Delta*T1) < 0.01)
alphacoh = -half*alpha0*I2*pow(gamma/gammap, 3);
else
{
Gamma = 1/T1 + gamma1;
I2sF = (I2/T1)/cmplx(Gamma, Delta);
betap2 = upsilon*(upsilon + gamma*I2sF);
beta = sqrt(betap2);
alphacoh = 0.5*gamma*alpha0*(I2sF*(gamma + upsilon)
/(gammap*gammap - betap2))
*((1+gamma/beta)*(beta - upsilon)/(beta + upsilon)
- (1+gamma/gammap)*(gammap - upsilon)/
(gammap + upsilon));
}
alpha1 = alphainc + alphacoh;
}

To get an idea as to the differences between the standard way of programming mathematical formulas and the proposed way, compare the version of a C++ routine entitled IHBMWM (inhomogeneously broadened multiwave mixing). This code was written in 1987.

The above function runs fine with C++ compilers, but C++ does impose some serious restrictions based on its limited operator table. For example, vectors can be multiplied together using dot, cross, and outer products, but there's only one asterisk to overload in C++.

In built-up form, the function looks even more like mathematics, as shown below. The ability to use the second and third versions of the program is built into the PS Technical Word Processor. With it we already come much closer to true formula translation on input, and the output is displayed in standard mathematical notation. Lines of code can be previewed in built-up format, complete with fraction bars, square roots, and large parentheses. To code a formula, you copy (cut and paste) it from a technical document into a program file, insert appropriate raised dots for multiplication and compile. No change of variable names are needed. Call that 70% of true formula translation. In this way, the C++ function on the preceding page compiles without modification. The code appears nearly the same as the formulas in print.

This macro effectively has only one goto and is almost as fast as a single compare.

Partner Profile | Privacy Statement | Why Passport | Testimonials
This site uses Unicode for non-English characters and uses Open Type fonts.
©2003-2007 Microsoft Corporation. All rights reserved.