# Basic Guide - Wiris CAS

**Find out how here**.

## Randomness

The random function in Wiris Quizzes is adaptable to many cases of use. For example, we'll show you how to remove the "0" from a random selection. The normal command would be something like:

By default, this includes all of the numbers between -10 and 10. If the number 0 supposes some sort of difficulty or wrong behavior for our question, we can remove it with the simple instruction:

We have to add brackets around the first list for this to work. As you may suspect, this can work for any other number we use instead of zero:

The above would produce a random number between -10 and 10, except the number 8. Or you can even do this with more than one number:

This would remove 8,-8, and 0 from the selection. As can be seen, we have many more options than it seems at first when creating a random variable.

So far we have retrieve integer numbers. We can also obtain real numbers

## Polynomials and expressions

Polynomials are created with numbers times a power of a variable.

We can sum, multiply, divide and, for instance, find roots of polynomials.

We can create a more complex expressions and operate with them.

## Vector and Matrix constructor

### Vectors

Vector are constructed with square brackets `[]`

, and the elements are separated by commas `,`

.

We can sum vectors or compute the scalar product between them.

### Matrices

Matrices are vectors of vectors, that is, vectors whose rows are vectors. We can create matrices with two different syntaxes

As vectors, we can sum and multiply matrices (as long as dimensions match)

### Element access

We can access a specific element of a vector using subindeces, that start on 1. In the same way, we can retrieve an element of a matrix

## Creating lists via comprehension

This section is a short guide to creating lists in Wiris Quizzes algorithms, using the commands `with`

and `where`

. This method of defining lists is based on the common mathematical notation of "set comprehension" or "set-builder notation", for instance:

We'll explain the commands through the following examples.

### Example 1

At the most basic level, `with`

simply provides a more compact form of writing long lists. We could write

or we could greatly simplify it to the following:

The command `where`

comes in when we want additional restrictions. To get only the even numbers, for example:

Alternatively we could, of course, have gone with:

### Example 2

In the first example the size of the list was fixed. However, using comprehension shows its most benefit when defining lists of variable size. Here for example is a list with random elements, of random size

As you may notice, the first expression need not explicitly depend on . We can think of as just a counter within a specified range. Then, we may or may not use it to define the list elements. It can also be any variable name we choose, as in the following:

### Example 3

The list comprehension notation can also be extended to more than one variable. In that case, we must specify the range for each variable used as a counter. For example, here is a list with all positive proper fractions in simplest terms, with single digit numerator and denominator:

Another recommendation illustrated in the above is to enclose each condition after `where`

in parentheses, if we have more than one joined by .

### Example 4

Finally, we note that the range for the counter variable can itself be a list, defined previously.

### Example 5

It is also possible to create matrices using this notation. For instance, creating a matrix with random coefficients is as simple as this:

## Geometry

Wiris CAS allows us to deal with geometrical figures such points, lines, planes and conic sections.

We can also create polygons and polyhedras, both in 2D and 3D.

We can also compute the distance between figures, the angle they form and compute the symmetry.

## Statistics

There are a lot of functions involving statistical functions, like mean, quantile, quartile... You can see a complete list here.

## User functions

We can create our own functions. As you can imagine, the `random`

command is very useful but it could be a bit tedious to write every time `random(-10,10)`

, for instance. Instead, we can create a function that generates a random number when called:

This way is very easy creating a matrix with random coefficients. Another more elaborated example is creating a function that constructs a tri-diagonal matrix given three numbers. Therefore, every time we want to create a tri-diagonal matrix, we just need to call this function with the upper-diagonal, diagonal and lower-diagonal terms.

## Programming

We can use some programming functions. You can see the basic ones here. For instance, creating a list as before, we can easily compute the square of the first primes.

## Plotter

WIRIS graphics live within a *plotter*. When this plotter is interactive then you have a toolbar that lets you change some of its configuration; center, zoom, show axes, ...

You can also change all the settings using commands. The available options are listed in the Manual (plotter).

You can first change options interactively, then get the equivalent commands using the button *Save plotter movements*.

One must distinguish between the general plotter options, and the particular options of each graphic object that lives in it. The options of objects are set using `plot()`

, and are also listed in the Manual (plot).

Here we'll discuss only the general plotter options, not the objects.

### Create and use

You can create new plotters using the command `plotter()`

. Each plotter has its individual configuration. The created plotters have sequential automatic names: `plotter1, plotter2, plotter3 ...`

but can be assigned to a variable to use another name. When a plotter is created, the command returns its name.

In the command `plot()`

, you can set the plotter to use. If not set then it will use the last created plotter. If there is no plotter yet, a new one will be created with default options. The command returns the name of the used plotter.

The command `represent()`

behaves like `plot()`

, but when you create a new plotter then it automatically changes some options. If you don't want this behavior then modify the options of `plotter1`

after.

Plotter options can be set at the time of plotter creation by using the command `plotter()`

, or later by using the command `attributes()`

. These options can be written as a vertical list by using the key combination `Shift + Enter`

.

Plotter options are of *Table* data type, so they can be manipulated as usual. You can get the options of an already created plotter by using the command `attributes()`

, and assign them to a variable. For example, one can access a value using parentheses.

Another example: you can combine multiple lists of options using the `&`

.

### Size

The dimensions of the displayed area can be set in two ways:

- Giving both
*width*and*height* - Or giving only one, and
*aspect_ratio*.

The dimensions of the window can also be set in the same way.

### Grid

The grid density is automatic and depends on the dimensions of the window and the displayed area. For example, to get a grid of 1 unit the *window_width* must be between 12 and 24 times the *width*.

In recent versions of WIRIS there are commands for controlling the density of the grid. And in addition to the main grid, you can use a sub-grid.

See this complete example: