PhysCalc Copyright (C) 1990 Marty White This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Help! PhysCalc is a physics calculator. This program provides you with the power of a programable scientific calculator and a universal unit converter all in one. At the prompt, you may enter an expression to be immediately evaluated, or a command. Commands start with a keyword and take various parameters. Expressions are evaluated using standard algabraic precidence: multiplication before addition, parenthesis first, ect. The following operators may be used: Addition + factorial ! modulo mod Subtraction - logical not not Multiplication * logical and and Division / logical or or Exponentiation ^ Parenthesis ( ) Built in functions are as follows: exp(x) - returns e to the x power ln(x) - returns the logarithm of x, base e log(x) - logarithm base 10 sqrt(x) - square root fact(x) - factorial, x must be a small integer sin(x),cos(x),tan(x) - Trig functions. x is in radians, unless other angular units are specified (as in sin(90 degrees)). arcsin(x),arccos(x),arctan(x) - Arc-trig functions. These return dimensioned units, so you will be asked to specify an angular unit (degrees, radians). integrate(f,a,b[,p]) - definite integral of f on the interval from a to b. The trapezoidal rule is used with p partitions. If not given, the last number of partitions specified is used. (Default p=20) PhysCalc does not make any distinction between upper and lower case. Commands: QUIT - returns to the operating system INFO - displays some information about the program. LET - assign a value to a variable name. Variable names may be up to 18 letters long. For example: LET lightspeed = 3e8 meters per second LET a = sqrt(c^2 - b^2) + 7 In the second example, the value (SQRT(C^2 - B^2)+7) would not be evaluated until variable (a) was called for, at which time the values of (c) and (b) would be looked up. A variable can be used in place of any value. You cannot, however, put unit names after a variable as in (N METERS PER SECOND). To force immediate evaluation when assigning a variable, use ':=' in place of '=' as in: LET b := a+2 Here, (a) will be evaluated right away, and (b)'s value will not change if (a)'s does. This saves time and memory. DEFINE - define a function. Examples: DEFINE f(x) = 2 * x^2 - (1/3) * x + 3.5 DEFINE square(number) number * number DEFINE funny_func(zip,zap,ping) = zip^3 / 12 megawatts * (zap + ping) DEFINE constant(c) = 42 User-defined functions may be used just like built in functions. Regular variables may be referenced, but variables with the same names as dummy paremters will not be accessible: LET X = 42 LET Y = 3 DEFINE F(X) = X^2 + Y F(2) Result: 7 F(x) Result: 1767 Functions may have multiple parameters and can be integrated with the integrate function. LIST - lists all variables and functions LIST - lists variables and functions LIST VAR - lists variables LIST FUNC - lists functions DELETE - deletes a variable or function. To delete a variable, type DELETE Examples: DELETE pi DELETE a An opening parenthesis must follow function names. To delete a function type DELETE Examples: DELETE f( DELETE g() FACTOR - Lists all factors and the prime factorization of an integer value. FACTOR 1984 + 5 would list all factors of 1989 and its prime factorization. TRACE - turns tracing mode on or off: TRACE ON or TRACE OFF. In tracing mode, each step of a calculation is displayed on the screen so you can see what it is doing. It's not very readable, though. Use CTRL-S or CTRL-NUMLOCK to pause if the display scrolls by too fast. This program also works with fractions. Fractions may be entered using a a backslash '\' to separate the whole number, numerator, and denominator. Some sample expressions using fractions: 1\2 + 0.0 Result = 0.5 1\1\2 + 0.0 Result: 1.5 1\2 + 1\3 Result: 5\6 FRACTION - sets fraction display mode. FRACTION IMPROPER - displays fractions as numerator\denominator. FRACTION MIXED - displays as integer\numerator\denominator. BASE - Set numeric base used for output, and default for input. An equal sign is optional. You can set the base from 2 to 36. The base itself is specified in decimal. BASE 10 - set to base 10 (decimal, startup default) BASE = 16 - set to base 16 (hexadecimal) BASE 8 - set to base 8 (octal) A number is assumed to be in the default base, unless prefixed by a base indicator: 0x, 0d, or 0b, for hex, decimal, and binary. 0x10 + 0d10 + 0b10 is the same as (16 + 10 + 2), which is 28 (base 10). DIMENSION - defines a new dimension. DIMENSION Simply declares a new fundamental dimension. DIMENSION Declares a compound dimension. An example: DIMENSION DISTANCE ;declare dimensions DISTANCE and TIME DIMENSION TIME DIMENSION VELOCITY DISTANCE PER TIME ;delcare compound dimension VELOCITY UNIT - defines a new unit. Usage: UNIT is the conversion factor to the standard unit for the specified dimensions. can be an dimension description, as in the DIMENSION command, or it can be a previously defined unit. Examples: UNIT METER 1.0 DISTANCE ;METER will be the standard unit UNIT FOOT .3048 DISTANCE ;a foot is .3048 the size of the standard unit UNIT YARD 3 FOOT ;a yard is 3 feet SAVE Save any dimensions, units, variables, or functions defined since startup. Data is written to file as human-readable text (which may be edited). This will not re-save the contents of the PHYSCALC.DAT file, which is loaded on startup, but only subsequent definitions. SAVE ALL Like SAVE, but saves all dimensions, units, variables, and functions, including those initialy loaded in from PHYSCALC.DAT. LOAD Loads in a file containing dimension, unit, function and variable definitions. Each line of the file is executed as if typed at PhysCalc's regular prompt. A semicolon marks the begining of a comment, and the rest of that line is ignored. Duplicate DIMENSION and UNIT definitions are ignored; duplicate variable and function definitions replace previous ones (just like at the prompt). SYSTEM Attempts to execute the given shell command. SYSTEM DIR would do a directory on WinDOS systems. A dimensioned or dimensional value is a number with a unit, such as 23 METERS or 12 LIGHTYEARS PER SECOND. All operators and functions do their best to work with dimensional numbers, but if you do something impossible (like add meters to days), you will be warned and the result will have no dimensions (and probably no meaning!). If not specified by the user, trig functions assume their arguments are in radians. Inverse trig functions will always return a unit of dimension ANGLE, which you will need to convert to Radians or Degrees (or your own angular unit). To enter a dimensional value, simply type the value followed by its dimensions. Dimensions can be raised to any integer power greater than 0. If the result of the calculations is a dimensioned number, you will be asked for a unit to convert to. Entering a unit will convert it (if valid). Enter a '?' to list all known units of that type and the default unit. The default unit is always metric and to use it just press enter. Entering a '?' at the main prompt will list all known dimensions and units. Entering '?' followed by a unit or dimension will list all known corresponding units. Abrieviations are listed (and defined) separately from the un-abreviated name. The abreviated version must be defined AFTER the un-abreviated version. All units can be entered as singular or plural. All units can have the following prefixes: exa,peta,tera,giga,mega,kilo, hecto,deca,deci,centi,milli,micro,nano,pico,femto, and atto. One letter abbriviations may be used for unambiguous prefixes (such as k for kilo). Unfortunately, there's no way for I or the computer to guess wether mm might mean milimeter, micrometer, megameter, or myriameter. When PysCalc tries to identify a unit or dimension you have entered, it uses this search algorithm: de-pluralize name compare with dimension names compare with unit names including any defined abbreviated unit names see if there's a scaling prefix (mega, kilo, ect.) if a prefix is found, remove it and start the search again. Plurals are automatically converted to singular using simple spelling rules, with built in exceptions for "inches" and "calories": Words ending in "ies" are changed to end in "y". If a word ends with a single "s", the "s" is truncated. NOTICE: when entering dimensions with powers, the '^' must immediately follow the unit. Use (meters^2), NOT (meters ^ 2) to indicate area. This is so the program can distinguish between things like 12 square meters and 12 meters to the power of 2, which is 144 square meters, definitely not the same! You can always use parentheses to avoid ambiguity. Here are some valid expressions (try them!): 12.8 meters 35 days + 1\2 hours 32 feet per second^2 (34 + 6) * 8 megajoules 4! * sin(30 degrees) + integrate(cos,0,PI/4,10) 45 kg per cc PI + 2.7395e-9 * 1\3 sqrt(35 meters^2) + 8 inches .5 kg * 4.18 kj per kg k * 3\9\13 k 150\1\2 pounds * (0.998 c)^2