Crystal Math - Version 0.5.7

Ogre Industrial

Last Guide Update: 7/15/2002 - 4:36 PM

Grapher is a math program which is currently under development. As of right now, I've only really worked on the math engine, and two simple interfaces. One is a console based app so that source code can be compiled for any 32 bit platfrom with a C++ compiler (this means all most all modern platforms), and the other is a Win32 dialog based program which allows for far greater ease of use, but is really just an interface to the same math engine (the Win32 version also includes an optional console type interface which acts exactly like the console edition).

Why use Crystal Math?
first of all, it's one hell of a lot better than using the Calculator program that comes with many OSes (because you write equations and do many other things that can't be done on computer versions of scientific calculators), and it doesn't cost anything (unlike real math apps like Mathematica, Maple, Matlab, etc.) Also the learning curve is almost nothing because the equation format is almost exactly like normal math. Soon however, once I'm happy with the engine, Crystal Math will have 2D and 3D graphers and such which will make the whole experience much better. And lastly, when ever something jumps into your head, sure it's easy to use those standard calculators, but it's even easier to use Crystal Math, the Win32 version has even made it so that you even push the exact same buttons to get an answer as if you were using a simple calculator. NOTE: to any of you who have used my previous math app Grapher, Crystal Math is Grapher's big brother boasting far more flexibility and power (the only lacking on Crystal Math's part being that there are currently no graphing utilities).

A Note on Version 0.5
Although it is fairly new, Version 0.5 offers the power of true symbolic math with a balanced mix of linear and object oriented code (written of course in C++). The different types (such as strings, expressions and real numbers) are all blended together to allow for seamless transition between them. The engine itself is primarily focused around expressions as opposed to numbers, as many other similar math platforms. As an example of how the engine works, let me explain how a command you enter is executed, first you enter in some text, this is then loaded into the program just like any other string, it is then transformed into an expression, which is then evaluated, all of this is done with standard function calls which means no special exceptions are made for the compiler, which means that the power of the compiler is always avialable for any function to use. If you don't understand what I just said, don't worry about it, you the user need never be bothered with such details, all you'll find is an easy to use and powerful math suite for your usage

Usage:
The calculator itself works the same way on both platforms, just type in the equation and it executes it. You can do simple math like "5+6" and it will give the answer, you also expand on this by adding parenthesis and using any of the functions listed below. Operator precidence is followed. Functions work like they do in real math, so "sin(90)" is 1 (if your in degrees mode).

Implimented Functions:
All the following functions have been implimented, but considering this is not the finished product, don't be surprised with little errors here and there (mostly round off stuff like 3.99999 inplace of 4).

  • + - plus

  • - - minus

  • * - multiply

  • / - divide

  • ^ - to the power of

  • = - equals (assignment operator)

  • == - is equal (test)

  • != - isn't equal (test)

  • < - is less (test)

  • > - is more (test)

  • >= - is greater than or equal to (test)

  • <= - is less than or equal to (test)

  • sin - sine

  • cos - cosine

  • tan - tangent

  • csc - cosecant

  • sec - secant

  • cot - cotangent

  • asin - arcsin

  • acos - arccos

  • atan - arctan

  • acsc - arccosecant

  • asec - arcsecant

  • acot - arccotangent

  • ln - natural log

  • log (base,value) - gets the log base base of value

  • exp (value) - raises e to the value given. In other words: e^x = exp x

  • sqrt - square root

  • abs - absolute value

  • rand (value) - returns a random number between 0 and the value given

  • nder (equation,variable,value) - numerically differentiate the equation with respect to variable at value

  • nroots (equation,variable,minimum,maximum) - numerically finds the roots of equation (with respect to variable) from minimum to maximum

  • nint (equation,variable,from,to) - numerically integrate the equation with respect to variable from from to to

  • sigma (variable,from,to,expression) - takes the sum of the values of the expression for all the values of variable from from to to (incrimenting by 1 each time)

  • eval (equation,expression1,expression2, ... ) - execute numerous expressions, and then evaluate the equation (e.g. eval((x+y)^2,x=2,y=3) gives 25 ). Any number of expressions is allowed. ALSO if you wish to use a variable you made (like "u" or "v") but you want it to be considered a value (and not a variable) write "eval(u)" (or whatever the variable is).

  • frombase (base,string) - converts string from base base to base 10

  • tobase (base,value) - converts value from base 10 to base base (NOTE: the return value is a string)

  • nintersects (equation1,equation2,variable,minimum,maximum) - numerically finds intersections of equation1 and equation2 from minimum to maximum(with respect to variable)

  • nextrema (equation,variable,minimum,maximum) - numerically finds the extrema of equation from minimum to maximum (with respect to variable)

  • testder (equation,derivative_of_equation,variable,minimum,maximum) - calculates the error of a derivative over a specific area (minimum to maximum) based on the original equation. Use it to test derivatives (hence the name). Both must be of variable

  • convert (value,unitNameFrom,unitNameTo) - converts value from unitNameFrom to unitNameTo. A list of valid units will be shown later. (e.g. convert(12,inches,feet) is 1

  • frac (value) - converts a decimal value into a fraction (e.g. frac(0.2) is "1/5")

  • ipart (value) - gives the integer part of a value (i.e. ipart(32.85) = 32 )

  • fpart (value) - gives the fractional part of a value (i.e. ipart(32.85) = 0.85 )

  • setmode (mode,...) - simply enter one or a series of modes to set them as active. Here is a the current list of modes: degrees, radians

  • tostring (anything) - convert almost anything into a string

  • toreal (anything) - convert almost anything into a real number

  • tovec (anything) - convert almost anything into a vector

  • toexp (anything) - convert almost anything into an expression

  • . (Period) - can be used to get (NOT SET) the value in a vecotor. ex: 5 + v.0 >> x

  • set (vector,index,anything) - sets the indexth variable of the vector to anything

  • dot (vector1,vector2) - returns the dot product of vector1 and vector2 (you can also use the '*' (multiply) operator)

  • BELOW are unfinished functions: (but they work pretty darn well)

  • der (expression,variable) - symbolically differentiate expression with respect to variable. Not too many rules have been implimented for it yet, still working a couple bugs out of the code. NOTE: system may sometimes display, DER (instead of der), but the user must always type "der"

  • simp (expression) - symbolically simplify, still has some problems as far as abstraction goes, but will be getting better. Plus a couple bugs

  • BELOW are functions that probably only developers will use:
  • group (expression) - groups the expression (i.e. changes "+(a,+(b,c))" into "+(a,b,c)")

  • isconst (anything) - is anything is constant or not (test)

  • issamevar (variable1,variable2) - is variable1 variable2 (used in conditions) (test)

  • isreal (variable) - is variable a Real (test)

  • isstring (variable) - is variable a String (test)

  • isexp (variable) - is variable a Exp (test)

  • isvec (variable) - is variable a Vector (test)

  • islist (variable) - is variable a List (test)

  • ... and many more to come


  • Constants:
    NOTE: you can change the values of these variables at run time (with for example "pi = 4.3"), so be careful.
  • pi - this is of course Pi
  • E - this is the constant e so that ln(E) = 1


  • Units:
    These are the units supported by convert
    Distance: mm, cm, km, inch, inches, feet, foot, ft, m, meter, meters, yard, yards
    Time: second, seconds, minute, minutes, hour, hours, day, days, week, weeks, year, years

    Base Converter:
    While you can use tobase and frombase to convert between bases, the Win32 version of Crystal Math also contains a base converter for converting numbers into a different base, which uses a very nice little interface. The four forms are Dec (decimal, base 10, which is what we use), Hex (hexadecimal, base 16, used in computers), Bin (binary, base 2, also used in computers), and Let (letter format, base 26, not really used but fun). Just type in the number in the appropriate section and the other values will be calculated. A note on "letter form", within this base 26 format, A is 0 and Z is 25, so BA is 26. One thing you may notice is that no Let number starts with A, (except 0), the reason is that A is 0, and putting a 0 in front of a number doesn't mean anything does it? Also, with base changer you may use lower case and upper case letters interchangeably.

    Equation Visualizer
    Currently (only in the console version) any equations you enter will be displayed as real math functions (like one thing over another for divide, a square root sign and such). See the screen shots of the console versio to know what I mean. I havn't recompiled the Linux version to do this yet, but it's comming tommorrow.

    Console Mode in the Win32 Edition
    When I use Crystal Math (for general math purposes), I primarily use the console option in the Win32 version (for development I prefer the standard console version though). You can access this by running the program and then selecting "Console" from the "Crystal Math" menu, or you can run the program with the command line option "console" (with no quotes). One idea is to make a shortcut to the program, and add "console" after the file name, that way you will automatically boot into the console mode. You may also note that after displaying any values in console mode, the type of the value is shows in [] next to it. This is mostly for development, don't worry too much about it.

    Examples:
    Simple Stuff:
    >1+2
       1 + 2  [exp]
    
       3  [real]
    
    
    >sin(pi*3)
       sin [ pi * 3 ]  [exp]
    
       0  [real]
    Proper use of expressions and variables:
    >u = x^2/(1+x)
             2
       u =  x     [exp]
           -----
           1 + x
    
         2
        x     [exp]
       -----
       1 + x
    
       0  [real]
    
    
    >der(eval u, x) >> du
       d  /   2   \
       -- |  x    | >> du  [exp]
       dx | ----- |
          \ 1 + x /
    
       2 * [ 1 + x ] * x + - /  2 \
                             \ x  /
       ----------------------------  [exp]
                         2
                [ 1 + x ]
    
       0  [real]
    
    
    >nder(u,x,5)
       nder [ u, x, 5 ]  [exp]
    
       0.972222  [real]
    
    
    >eval( du, x=5)
       0.972222  [exp]
    
       0.972222  [real]
    
    Developers Needed:
    If you are interested in working on this project, please contact me. Also if you wish to compile it for Mac, UNIX (or whatever), I will supply you with the source code. Also if you wish to impliment a GUI on one of these platforms I assure it is very simple, the console GUI code is only about 100 lines. Also remember, the true power of Crystal Math has yet to come and will be in the form of true symbolic mathematics

    A Note From the Developer:
    I sincerely hope Crystal Math is as much a help you as it has been to me. If there is anything you wish changed or added to Crystal Math, please contact me with any good ideas. I can be reached at OgreCorp@Yahoo.com. Crystal Math is of course free to anyone who wants it, but donations are always gratefully accepted ("favors" are also much appreciated form any female users out there).

    Developers Involved:
    Lewey Geselowitz - Creator, and main programmer
    David Edelstein - Numerous improvements regarding the scripting engine
    Credits:
    Developed by Ogre Industrial
    Created by Lewey Geselowitz
    Crystal Math at Source Forge