DOC PREVIEW
Columbia COMS W4115 - Physicalc - A Language for (simple) Scientific Computation

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Physicalc:A Language for (simple) Scientific ComputationBrian Foo, [email protected] Jiang, [email protected] Li, [email protected] Sierra, [email protected] Proposal – September 25, 20071 IntroductionPhysicalc is a programming language for scientific computation, designed forstudents studying beginning and intermediate-level physics, chemistry, or othersciences.Computer algebra systems are typically oriented towards higher mathemat-ics, making them ill-suited to the sorts of calculations done by high-school andundergraduate science students. At the same time , some computer algebrafeatures, such as symbolic computation using irrationals, could be helpful tostudents. Physicalc presents itself initially as an intelligent calculator that un-derstands physical units like “meters/second.” It can also solve simple prob-lems involving physical equations. For more advanced users, it supports realprogramming in an imperative style.Physicalc is intended primarily as an educational tool, but may also be usefulfor exploratory data analysis in scientific fields.2 Language Overview2.1 InterpreterPhysicalc is an interpreted programming language. The interpreter is written inJava and can be run either interactively or on a file containing Physicalc sourcecode. The interface is text-mode, although a GUI could be layered on top of it.2.2 SyntaxPhysicalc syntax is as simple as possible, using mostly English words, morereminiscent of BASIC than C. Statements are separated by newlines. State-ment blo cks are enclosed in “do. . . done” pairs. Standard imperative-language1features such as loops, if/then/else branching, and user-defined functions areprovided. Standard mathematical operators are provided, with the addition of‘^’ for exponentiation.Identifiers are both case-insensitive and inflection-insensitive. That is, ‘new-ton’, ‘newtons’, ‘Newtons’, and ‘NEWTON’ are all the same identifier.2.3 TypesThe Physicalc type system uses physical units like “meters” and “seconds” astypes instead of mathematical partitions like “integers” and “floats.” Unit typescan be combined algebraically to form derived types such as “Newton*meters”or “meters/second.”All numbers are arbitrary-precision decimals or rationals. Limited symboliccomputation is supported—irrational numbe rs such as π and√2 can be used incalculations and returned in results, or converted to decimals with an arbitrarydegree of precision. Complex numbers are supported.Two-dimensional vectors may be written either as “x, y” components or asmagnitude-direction pairs, e.g. “3 Newtons at 36 degrees.” Directions given asangle measures are assumed to be measured counterclockwise from the x-axis.The following operations are supported on all types: addition, subtraction,multiplication, division, exponentiation, and roots.2.4 SemanticsA Physicalc program consists of definitions, queries, and expressions.2.4.1 Definitions1. Quantities define the types of measurements that can be made. Thesemay be fundamental quantities, such as length, or derived ones, such asmomentum. Quantities can be defined in terms of other quantities. Ex-amples:def quantity distancedef quantity timedef quantity velocity = distance / time2. Units define units of measureme nt for a quantity. Units may be definedin terms of other units. Examples:def unit meter for distancedef unit centimeter = 0.01 metersdef unit foot = 30 centimeters23. Aliases define alternate names for quantities or units. They may be usedfor abbreviations or alternate names. Examples:def alias length for distancedef alias N for Newtondef alias feet for foot4. Constants are fundamental physical constants that can be used as quan-tities in equations. Example:def constant universal_gravitation = 6.67428e-11 N*m^2/kg^25. Equations define algebraic relationships between quantities. They arewritten as expressions followed by a series of declarations describing thequantities of each variable. Example:def equation Fg = G * m1 * m2 / r^2 whereFg = gravitational_forceG = universal_gravitationm1 = massm2 = massr = distancedone6. Functions are standard imperative-style functions, which may be recur-sive. GCD in Physicalc looks like this:def function gcd(a,b)while a != b doif a > b doset a = a - belseset b = b - adonedonereturn adone2.4.2 QueriesQueries ask questions of the form “find unknown given knowns.” Example(syntax to be determined):find mass in pounds givenforce = 12 Newtonsacceleration = 3 m/s^2done3Queries work by exploring the graph of relationships am ong physical quan-tities and units defined in a program. Based on the types of the givens andthe requested type, the interpreter infers the correct sequence of calculationsand/or conversions to be performed.2.4.3 ExpressionsExpressions are any combination of mathematical operators and function calls.3 Prior Art3.1 Google CalculatorSup e rficially, the behavior of Physicalc resembles that of the Google Calculator[3],which can answer queries like “160 pounds * 4000 feet in Calories.” The differ-ences from the Google Calculator are:1. Physicalc is a full-featured imperative programming language with vari-ables, loops, branching, and user-defined functions;2. Physicalc programs can define new units and the relationships amongthem; and3. Physicalc can infer the necessary calculations to obtain a desired resultgiven a set of known variables.3.2 Computer AlgebraPhysicalc has some features in common with computer algebra systems suchas Maxima[8], Octave[2], and MATLAB[7], although it is much simpler. Asfar as the authors know, none of those systems allow for unit types or inferredcalculation. Also, most such systems are oriented towards higher mathematicsand are far too c omplex to be useful to beginning science students.Various Java libraries [1, 4, 6] provide computer algebra features; these maybe useful in the implementation of Physicalc, probably with some modification.3.3 LogicIn some ways Physicalc behaves like logic languages such as Prolog, in which theuser enters a series of facts and then enters queries about those facts. However,Physicalc is not a general-purpose logic or constraint programming language.3.4 JScienceJScience[5] is an open-source Java library for calculations involving SI units andarbitrary-precision arithmetic. JScience’s unit classes are of limited usefulnesswithin Physicalc because they are designed to be part of a statically-compiled4Java


View Full Document

Columbia COMS W4115 - Physicalc - A Language for (simple) Scientific Computation

Documents in this Course
YOLT

YOLT

13 pages

Lattakia

Lattakia

15 pages

EasyQL

EasyQL

14 pages

Photogram

Photogram

163 pages

Espresso

Espresso

27 pages

NumLang

NumLang

6 pages

EMPATH

EMPATH

14 pages

La Mesa

La Mesa

9 pages

JTemplate

JTemplate

238 pages

MATVEC

MATVEC

4 pages

TONEDEF

TONEDEF

14 pages

SASSi

SASSi

16 pages

JTemplate

JTemplate

39 pages

BATS

BATS

10 pages

Synapse

Synapse

11 pages

c.def

c.def

116 pages

TweaXML

TweaXML

108 pages

Load more
Download Physicalc - A Language for (simple) Scientific Computation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Physicalc - A Language for (simple) Scientific Computation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Physicalc - A Language for (simple) Scientific Computation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?