/************************************************************************** SOLVE Copyright (C) C. Kenneth Curtis, 1993 46 Woodland Drive, Califon, NJ 07830, USA SOLVE is a DOS command line mathematical expression solver for engineers and scientists. Expressions like 2.15 + 6 * sin(pi / 2) are evaluated and the result displayed. SOLVE contains many built in functions including decimal- hexadecimal conversions. SOLVE may be used without any fees. The SOLVE.TXT and SOLVE.EXE files may not be altered, but compression is allowed for up/down loading to/from electronic bulletin boards. No one is authorized to sell these files or distribute them for a fee without written permission from the author. **************************************************************************/ To use SOLVE, simply type the expression immediately after the program name, hit [Return] and the answer appears. For example SOLVE 2.15 + 6.0 * sin(PI/2) Multiple expressions can be handled in a single command by separating them with semicolons. The results from the one statement can be used as input for subsequent statements. For example SOLVE a = 1.7 * 32; b = .603 * 32; arctan(a,b) The first equation calculates a value for a, the second computes b's value and the third finds the arctangent using a and b. Spaces may be used for legibility, but they are not required. At least one space is required between the program name and expressions. SOLVE is not case sensitive. Upper or lower case letters may be used. The following are equivalent: solve 7 * (sin(.123) + .456) SOLVE 7*(SIN(.123)+.456) SoLvE 7 * ( S i N ( . 1 2 3 ) + . 4 5 6 ) SOLVE assumes all computations are integers unless it encounters a floating point value. Then floating point is assumed. However if a semicolon is encountered, SOLVE reverts back to integer mode where it stays until it sees a floating point value. Integer values are between -2,147,483,648 and 2,147,438,647. Floating point numbers may be represented in scientific notation, eg 1.23E-4. The mantissa must contain a decimal point. Hexadecimal values begin with a # symbol, include the characters 0 through 9 and A thru F, and may include a decimal point. If the first character after the # is an 8 through F, the value is considered negative. #36 = 54 decimal #A2 = -94 decimal #0A2 = 162 decimal #11.3 = 17.1875 decimal SOLVE uses the mathematical operators = assignment, eg X = 1 + 9 + addition, binary operation between 2 values, eg 7 + 5 - subtraction or negation, binary operation between 2 values, eg 7 - 5 * multiplication, eg 29.0 * 32.3 / division, eg 15.0 / 3.3333 ** raised to the power of, eg 3 ** 5 + unary plus, operates on single value, eg 7 * +(14 * 3) - unary minus, operates on single value, eg 7 * -sin(.5) Operators have a precedence. operator precedence ----------- ---------- = 1 + - 2 * / 3 ** 4 unary + - 5 SOLVE reads left-to-right but operations with higher precedence will be computed first. In the expression 5 + 4 ** 3 / 32 4**3 equals 64 will be evaluated first. Then 64 will be divided by 32 equals 2 will be evaluated next, and lastly 5 + 2 equals 7 will be computed. Parenthesis may be used to assure the order of computation. In the next example, the sum of 5 and 4 will be multiplied by 7 resulting in 63. (5 + 4) * 7 Variable names may use letters, digits and underscores but must begin with a letter. Named variables, like tau below must be assigned a value before they may be used. SOLVE exp(tau = - 5000 * 2.2e-9) + 1 - tau; SOLVE has the following built in floating point constants PI = the number of radians in 180 degrees SQRT2 = square root of 2.0 SOLVE implements the functions listed below Trigonometric (Note: all return floating point values) Function Description ------------ --------------------------------------------------- sin(r) sine of r, r is in radians cos(r) cosine of r, r is in radians tan(r) tangent of r, r is in radians arcsin(x) angle in radians whose sine is x arccos(x) angle in radians whose cosine is x arctan(y,x) angle in radians whose tangent is y/x deg(r) degrees in r, r is in radians rad(d) radians in d, d is in degrees Powers (Note: all return floating point values) Function Description ------------ --------------------------------------------------- sqrt(x) square root of x ln(x) natural logarithm of x log(x) logarithm of x exp(x) exponent, e to the power of x Results can be displayed in hexadecimal by embedding the grave symbol (backward apostrophe) in the expression. solve `-4*3 displays as #F4 = -12 Floating point values can be displayed in hexadecimal as long as the result fits in 10 characters to the right of the decimal point and 10 characters to the left (approximately 5.4975e+11). solve `44.4444 displays as #2C.71C432CA57 = 4.4444400000e+01 Notes: 1. To get help, type SOLVE with no arguments. 2. Results will be accurate for practical sized numbers. But errors can occur with huge numbers which exceed 1.0e307 or division by a tiny number which results in a huge number.