print 1 minute | Arithmetic | Analysis | Geometry | Statistics | Menus, icons,... Mathematical Objects | Linear algebra | Functions | 2D Graphics | Combinatorics | Toolbar WIRIS ++ | Equations and systems of equations | Progressions | 3D Graphics | Units of measurement | Primary
WIRIS ++

This chapter considers a set of features which significantly increase the potential of WIRIS. We recommend most users study them in order to help them or their students get started in the world of programming. Readers of this chapter are expected to have prior knowledge of programming. Note that the language that we use here may be a little more technical than users are familiar with.

The following sections are included in this chapter:

 >>fast Programming language if... while... for... repeat... Data structures ranges boolean numbers domains rules and substitutios divisors relations

Information about boolean numbers and logical operators The following boolean numbers, which have a fundamental role in programming, are discussed below.

if...:  Icon or , sentence
if  B  then  A  end
if  B  then  A  else  A2  end
if  B  then  A  else_if  B2  then  A2  else  A3  end

Carry out the instructions in A if the following condition is met B . If the condition is not met and there is an elsestatement, then the instructions below are carried out A2 . It is also possible to have multiple conditions and various groups of instructions by inserting conditional else_if statements from the programming tab menu.

while...:  Icon , sentence
while  B  do  A  end

Carry out the instructions in A if the following condition is met B .

for...:  Icon , sentence
for  R  do  A  end

Carry out the instructions in A over the range R .

repeat...:  Icon , sentence
repeat  A  until  B

Carry out the instructions in A until the following condition is met B .

Let's complete the description of data structures in the chapter Mathematical Objects.

ranges: These are objects of form a..b or a..b..d where a, b and d are real numbers (a..b equivalent to a..b..1). If d is a number other than 0, the range a..b..d represents the list formed from the elements of the arithmetic progression a, a+d, a+2d, ..., not exceeding b. If d is zero the range represents an empty list. For example, 1..6 represents {1,2,3,4,5,6}, 1..6..2 represents {1,3,5} and 6..1..-3 represents {6,3}.

The function list list applied to a range returns the list which it represents.

boolean numbers: These are the logical constants true or false, which correspond to the values true and false, respectively. Principally, these can be obtained by applying the operator ? to equations and inequalities.

The logical operators, fundamental to the definition of conditions in control statements, are

Logical operator Symbol
conjunction - and
disjunction - or
negation - no not

Let's see some examples of how they behave:

domains: Mathematical objects in WIRIS can be classified in mathematical sets. We call these sets, domains. Some examples of domains are Integer, Rational, Irrational, Real and Polynomial.

Using the command is?, it is possible to find out whether an object is in a domain.

To work with domains, WIRIS offers the following operators (equivalent to logical operators): & , | , not, which work like the intersection, union and complement operators with sets. Accordingly, the following relationship exists between operators, which allows us to work in a similar way in different mathematical structures.

Logical operator Set orperator Symbol
conjunction - and: intersection: &
disjunction - or: union: |
negation - no complement not

Finally, is should be mentioned that the function imply? allows us to find out whether one domain is contained within another or not, and get_domain returns the domain that an object belongs to.

It is especially interesting to use domains in function definitions. This permits the user to define discontinuous functions, according to the domain, and to restrict the values over which a function is defined.

rules and substitutios: From the syntactic point of view, a rule is a list of objects of type x=>y or x:=>y. The variable or template is called x depending on whether it is a variable or not, respectively. The image is called y and a pair is of the form x=>y or x:=>y. A substitution is a rule defined for variables exclusively. If the user chooses =>, it uses the value of y to define the rule. On the other hand, if the user chooses :=>, it considers y as a variable for purposes of defining the rule.

The symbols => and :=> can be created with the icons and , respectively.

When applying a rule to an expression, all occurrences of each template (or variable) in the expression are replaced by the image of its template (or variable). The terms that do not match the template (or variable) do not change.

divisors: From the syntactic point of view, a divisor is a vector of objects of type x->y. It can be said that x is an index, y is its associated value and x->y is a pair within the divisor. To retrieve the value associated with an index, apply the object to the divisor. If there is no index associated, the result is 0.

The symbol -> can be created using the icon .

Divisors are particularly relevant in several contexts. For example, the structure returned by the function factor is a Divisor, which has as indices the prime divisors of the factored object (such as a whole number or a polynomial for example) and its values are the exponents of the these prime divisors.

Another important quality of divisors is that they can be added, and that the sum is defined such that the values of each index remain summed. For example, when a product is factored this returns the sum of the divisors obtained by factoring the factors.