Ordinary Differential Equation Solver Language (ODESL) Reference Manual

Similar documents
JME Language Reference Manual

The Warhol Language Reference Manual

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Sprite an animation manipulation language Language Reference Manual

9 Using Equation Networks

Lexical Considerations

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

The PCAT Programming Language Reference Manual

Lexical Considerations

1 Lexical Considerations

Petros: A Multi-purpose Text File Manipulation Language

Mirage. Language Reference Manual. Image drawn using Mirage 1.1. Columbia University COMS W4115 Programming Languages and Translators Fall 2006

The SPL Programming Language Reference Manual

Language Reference Manual simplicity

Spoke. Language Reference Manual* CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS. William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03

Introduction to Python, Cplex and Gurobi

XQ: An XML Query Language Language Reference Manual

GraphQuil Language Reference Manual COMS W4115

CMAT Language - Language Reference Manual COMS 4115

PROGRAMMING WITH MATLAB DR. AHMET AKBULUT

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof.

String Computation Program

Learning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104)

Typescript on LLVM Language Reference Manual

Chapter 2. Outline. Simple C++ Programs

BoredGames Language Reference Manual A Language for Board Games. Brandon Kessler (bpk2107) and Kristen Wise (kew2132)

Review of the C Programming Language for Principles of Operating Systems

Language Reference Manual

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

SFPL Reference Manual

The pixelman Language Reference Manual. Anthony Chan, Teresa Choe, Gabriel Kramer-Garcia, Brian Tsau

MATLIP: MATLAB-Like Language for Image Processing

Programming Languages & Translators. XML Document Manipulation Language (XDML) Language Reference Manual

DaMPL. Language Reference Manual. Henrique Grando

Language Reference Manual

d-file Language Reference Manual

ARG! Language Reference Manual

GOLD Language Reference Manual

CHIL CSS HTML Integrated Language

L-System Fractal Generator: Language Reference Manual

EZ- ASCII: Language Reference Manual

Chapter 4: Basic C Operators

Java+- Language Reference Manual

FotoScript: The Language Reference Manual

Operators Functions Order of Operations Mixed Mode Arithmetic VOID Data. Syntax and type conventions Using the Script window interface

VENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

UNIT- 3 Introduction to C++

VLC : Language Reference Manual

Sketchpad Graphics Language Reference Manual. Zhongyu Wang, zw2259 Yichen Liu, yl2904 Yan Peng, yp2321

SMURF Language Reference Manual Serial MUsic Represented as Functions

7 Control Structures, Logical Statements

Review of the C Programming Language

Data Types and Basic Calculation

GBIL: Generic Binary Instrumentation Language. Language Reference Manual. By: Andrew Calvano. COMS W4115 Fall 2015 CVN

ASML Language Reference Manual

egrapher Language Reference Manual

YOLOP Language Reference Manual

Full file at

CS4120/4121/5120/5121 Spring 2016 Xi Language Specification Cornell University Version of May 11, 2016

IPCoreL. Phillip Duane Douglas, Jr. 11/3/2010

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

Angela Z: A Language that facilitate the Matrix wise operations Language Reference Manual

RTL Reference 1. JVM. 2. Lexical Conventions

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

Digital Image Analysis and Processing CPE

DINO. Language Reference Manual. Author: Manu Jain

Introduction to MATLAB

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

Goals for This Lecture:

COMS W4115 Programming Languages & Translators FALL2008. Reference Manual. VideO Processing Language (VOPL) Oct.19 th, 2008

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

CHAD Language Reference Manual

Crayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361)

IC Language Specification

Introduction to Engineering gii

Decaf Language Reference

Language Reference Manual

easel LANGUAGE REFERENCE MANUAL

Creating a C++ Program

Unit-II Programming and Problem Solving (BE1/4 CSE-2)

C++ Programming Lecture 11 Functions Part I

Engineering Problem Solving with C++, Etter/Ingber

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

Programming for Engineers Introduction to C

BASIC ELEMENTS OF A COMPUTER PROGRAM

X Language Definition

Introduction to Matlab

Dr Richard Greenaway

CLIP - A Crytographic Language with Irritating Parentheses

PieNum Language Reference Manual

C: How to Program. Week /Mar/05

Chapter 1 Introduction to MATLAB

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.

CSC Web Programming. Introduction to JavaScript

Custom Variables (Virtual Variables)

Reference Grammar Meta-notation: hfooi means foo is a nonterminal. foo (in bold font) means that foo is a terminal i.e., a token or a part of a token.

Transcription:

Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE s) numerically for initial value problems (IVP s). It provides a subset of MATLAB s capability for manipulating numbers, mathematical expressions, and matrices, and numerically solving IVP s. The syntax of ODESL is also similar to that of MATLAB. A program written in ODESL is first translated to a JAVA program and then compiled to run on Java Virtual Machine (JVM). 2. Lexical Conventions There are six kinds of tokens: identifiers, keywords, numbers, strings, expression operators, and other special symbols. White spaces, tabs, newlines and comments are used to separate tokens, and they are ignored in other situations. At least one white space character is required to separate adjacent identifiers and constants. 2.1. Comments The start of a comment is marked by the character % The of a comment is marked by a newline character. Anything between the % and newline characters will be ignored by the compiler. 2.2. Identifiers An identifier is a sequence characters consists of alphabets and digits. The first character must be an alphabet. The underscore _" character counts as an alphabet it cannot be used as the first character in an identifier. Upper and lower case alphabets are considered different. There is no limit to the length of identifiers. 2.3. Reserved Keywords The following is a list of reserved keywords that cannot be used for other purposes: break continue elseif false for function If true while 2.4. Numbers

A number consists of a sequence of digits, followed by an optional decimal point., followed by an optional e, followed by optionally signed integer. All numbers except those used as indices for for loops and matrices are assumed to be double precision integers. Indices are assumed to be integers. 2.5. Strings A string is a sequence of surrounded by double quotes. 2.6. Special Symbols The following special symbols are used in the language for various purposes such as expression mathematical and logical operations, indicating comments and creating matrices. + - * / ^ = == < > <= >= ==!= &! ( ) [ ], : % ; 3. Types The types in this ODESL are not explicitly specified in the program. Because an ODESL program will be translated into a JAVA program, the data type of a variable is determined at compile time. The ODESL compiler determines the data type of a variable or a value returned by a function using the following rules: if a variable is assigned a value of true or false, then that variable is a boolean. All numbers are assumed to be double precision floating points except those without a decimal point and e. Numbers without a decimal point and e are assumed to be 32-bit integers. ODESL also has a build-in data type matrix which is an m by n matrix. A variable is of type matrix if its value is assigned by using a list of numbers enclosed in [ ]. A user-defined function specified by a function keyword is also a build-in data type in ODESL. 4. Expressions The following sections list the expressions and expression operators used in ODESL. The expression operators are listed in order of precedence (highest precedence first). For example, the expression operator in section 4.3 has higher precedence than that in section 4.4. Within each subsection, the operators have the same precedence. Left- or right-associativity of the operators are also specified.

4.1. Primary Expressions 4.1.1. Identifier An identifier is bounded to an assigned value. The data type of the identifier deps on the value of the right-hand side of the assignment operator. 4.1.2. Numbers A number is a constant and is evaluated to itself. 4.1.3. Strings A sequence of characters enclosed in double quotes. 4.1.4. ( expression ) A parenthesized expression evaluates to the same value as the expression enclosed by the parenthesis. 4.1.5. Access to elements of matrices This primary expression consists of a matrix identifier followed by either one index or two indices separated by comma enclosed by parentheses ( ). Access to elements in a matrix can also be done by enclosing one or two range specifiers (Section 4.1.6) separated by comma in parenthesis. 4.1.6. Access to elements of matrices integer1:step:integer2 is a range specifier denoting integer ranging from integer1 to integer2 with a interval equals to step. Matrix access can also be used create matrices with maximum size indicated by the indices enclosed in the parentheses. 4.1.7. 1D or 2D matrix creation A 1-dimensional matrix can be created by enclosing its elements by [ ] with the elements separated by,. A 2-dimensional matrix can be created by enclosing its elements by [ ] with, separating elements in the same row and ; separating elements in the same column. 4.1.8. Function calls A function call is a primary expression followed by parentheses enclosing a list of argument separated by commas. However, the number of arguments can be zero. Each argument is an expression. 4.2. Mathematical Expressions Mathematical expressions take primary expressions as operands.

4.2.1. Unary Operator: + expression + expression evaluates to the expression itself 4.2.2. Unary Operation: - expression - expression evaluates to the negative value of the expression 4.2.3. Power operator: ^ x ^ y: x to the power of y. x can be a scaler or a matrix. y must be a scaler. If x is a matrix, then each element of the matrix will be raised to the power of y. The associativity of the power operators is to the right. 4.2.4. Multiplicative operators: * and / The following binary operations are possible: m*n: where m and n are matrices, and the size of m and n are correct for matrix multiplication. This evaluates to the matrix multiplication of m and n. x*y: where x and y are scalers. This evaluates to x times y. m*y: where m is a matrix and y is a scaler. This results in a matrix where every element of the matrix is multiplied by y. x/y: where x and y are scalers. This evaluates to x divided by y. m/y: where m is a matrix and y is scaler. This results in a matrix hwere every element of the matrix is divided by y. 4.2.5. Additive operators + and - Binary operators +, - denote addition and subtraction. They can be used on two scalers, two matrices of the same size, or a scaler and a matrix. If both sides of the operators are not scaler or matrix, the scaler will be added to or subtracted from every element of the matrix. These operators group left to right. 4.3. Relational Operators The relational operators listed below group left-to-right. All relational operators yield true if the relation is true, and false if the relation is false; 4.3.1. expression < expression (less than) 4.3.2. expression>expression (greater than) 4.3.3. expression<=expression (less than or equal to) 4.3.4. expression>=expression (greater than or equal to) 4.4. Equality Operators The equality operators behave the same as relational operators. But they have lower precedence.

4.4.1. expression == expression (equal to) 4.4.2. expression!= expression (not equal to) 4.5. Logical not operator:! expression The! operator takes relational expressions as operands and it groups left-to-right. The result is the logical negation of the operands 4.6. Logical and operator: expression & expression The & operator takes two relational expressions as operands and it groups left-toright. The result is the logical and of the two operands. This operator is shortcircuited. 4.7. Logical or operator: expression expression The operators takes two relational expressions and operands and it groups left-toright. The result is the logical or of the two operands. The operator is short-circuited. 5. Statements If not otherwise indicated, statements are executed in sequence. 5.1. Expression statement Most statements are expression statements which are expressions that are terminated by a semicolon ;. 5.2. Statement list A is a list of one or more statements separated by ; 5.3. Assignment statement The format of the assignment statement is: Identifier = expression. The following are examples of assignment statements: a=1; a=1.2e3; a=[1,1,1;2,2,2;]; 5.4. Conditional statement The possible formats of the conditional statements are listed in the following sections. 5.4.1. If-else if ( logical expression) else (optional)

if the logical expression after if is true, then the first is executed. Otherwise, the second optional under else is executed. 5.4.2. If-elseif-else if (logical expression) elseif (logical expression).. else (optional) if the logical expression after if is true, then the first is executed. Following the if statement, there can be any number of elseif statements. If the logical expression in the if statement is false, then the inside the first logical expression after elseif that evaluate to true will be executed. If the logical expressions after both if and elseif statements return false, then the optional under else will be executed. 5.5. for statement This statement is an iterative statement in the following format: for ( identifier = range) The number of iterations is determined by the range specifier discussed in Section 4.1.6. As long as the value of the identifier is less than or equals to the highest value in the range, the statements in the will be excuted. 5.6. while statement This statement is an iterative statement in the following format: while (logical expression) The is executed repeatedly as long as the value of the logical expression remains true. The test takes place before each execution of the. 5.7. break statement The statement

break causes the termination of the innermost for or while iterative statement. Control is passed to the statement following the terminated statement. 5.8. continue statement The statement: continue causes the current iteration of the innermost iterative statement to terminate and proceed to the next iteration. 6. Function definition A function is defined using the following format: function [var1, var2, ] = functionname (argument1, argument2, ) A function is created using the function keyword followed by a optional list of return variables separated by commas and enclosed in [ ], followed by =, followed by the name of the function, and then a list of arguments separated by commas and enclosed in parentheses. The data type of all the return variables must the same. The list of return variables is essentially a 1D matrix. 7. Build-in functions 7.1. disp(expression) This function displays the value of the expression on screen. 7.2. save(filename, expression) This function saves the value of the expression to an ASCII file with name filename. If the expression evaluates to a single number, the number is stored in the file. If the expression evaluates to a matrix, then the file will contain the matrix with each elements separated by spaces. 7.3. load (filename) This function loads a value of matrix stored in a file with name filename. 7.4. Matrix functions 7.4.1. width(matrix) This function returns the width of a matrix. 7.4.2. height(matrix) This function returns the height of a matrix. 7.4.3. zero(m, n)

This function creates a m by n matrix whose elements all have values equal to zero. 7.5. Mathematical functions The following lists the build-in mathematical functions of ODESL: abs(x) exp(x) log(x) sin(x) cos(x) tan(x) asin(x) acos(x) atan(x) absolute value of x e x natural log of x sine of x cosine of x tangent of x arc sine of x arce cosine of x arc tangent of x can be either double or matrix. y can only be a double or integer. If x is a matrix, the math operation will be applied to each element of the marix. 8. Scope rules ODESL uses static scoping. There are two types of variable scopes: global and local. A global variable is a variable that is assigned a value outside of a function. Global variables can be used anywhere inside a program except when there is a local variable of the same name in a function. Global variables exist until the termination of the program. A local variable is a variable that is assigned a value inside a function. Local variables can only be used inside the function in which it was first assigned a value, and it cannot be used outside of that function. If there is a global variable and a local variable with the same name inside a function, the value of the local variable will be used instead of the global variable.