1  Getting started

1.1  Starting Xcas

Xcas is available from http://www-fourier.ujf-grenoble.fr/~parisse/giac_fr.html. This page also has information on installation. Once installed, the way to start the program depends on the operating system.

• Under Windows, there should be a shortcut xcasen.bat that you can click on.
• Under Linux, you can either find it on a menu provided by the desktop environment, or enter xcas & in a terminal window.
• Under MacOS, you can click on xcas in the Applications menu.

For this tutorial, you will mostly be working with the command line, which will be a white rectangle next to the number 1. There you can enter a command, after which there will be a window with the result, followed by another command line with the number 2.

1.2  XCas as a calculator

Once you have started Xcas, you can immediately use it as a calculator. Simply type in the expression that you wish to use using the standard arithmetic operators; namely + for addition, - for subtraction, * for multiplication, / for division and ^ for exponentiation. If you enter

34+45*12

you will get

 574

If you enter

2/3 + 98/7

you will get

 44 3

The operators have a standard order of operations, and parentheses can be used for grouping. (Brackets have a different meaning, see section 3.5, “Lists, sequences and sets”.)

Notice that if you enter integers or other exact values, Xcas will give you the exact result. If you enter an approximate value, such as a number with a decimal point (computers regard numbers with decimal points as approximate values), then Xcas will give you an approximate result. For example, if you enter

2/3 + 3/2

you will get

 13 6

but if you enter

2/3 + 1.5

you will get

 2.16667

You can also get a decimal approximation using the evalf function. If you enter

evalf(2/3 + 3/2)

you will get

 2.16667

By default, Xcas will give you 12 decimal places of accuracy in its approximations, but this is configurable (see section 2.3, “Configuration”).

Xcas also has the standard functions, such as sin, cos, asin (for the arcsin), log (for the natural logarithm). It also has common constants such as pi, e and i.

The trigonometric functions assume that angles are measured in radians. (This can be configured, see section 2.3, “Configuration”.) If you enter

sin(pi/4)

you will get

 2
2

1.3  Functions and variables

Xcas can work with expressions and variables as well as numbers. A variable in Xcas needs to begin with a letter and can include numbers and underscores. If you enter

x^2 + x + 2*x + 2

you will get

 x2 + 3*x + 2

You can give a variable a value with the assignment operator, :=. To assign the variable myvar the value 5, for example, you can enter

myvar := 5

If you later use myvar in an expression, it will be replaced by 5; entering

myvar*x + myvar^2

will result in

 5*x + 25

The assignment operator can also be used to define functions. To define the squaring function, for example, you can enter

sqr(x) := x^2

Afterwards, whenever you enter sqr(expression) you will get the expression squared. For example, entering

sqr(7)

will return

 49

and entering

sqr(x+1)

will result in

 (x+1)2

1.4  Simplifying expressions

When you enter an expression into Xcas, some simplifications will be done automatically. For example, if you enter

a := 3
b := 4

and

a*b*x + 4*b^2

you will get

 12*x + 64

Xcas has several transformations in case you want an expression to be simplified beyond the automatic simplifications, or perhaps transformed in another way. Some examples are:

expand
This will expand integer powers, and more generally distribute multiplication across addition. For example, if you enter
expand((x+1)^3)
you will get
 x3 + 3*x2 + 3*x + 1
factor
This will factor polynomials. For example, if you enter
factor(x^2 + 3*x + 2)
you will get
 (x + 1)*(x + 2)

1.5  Graphs

Xcas has several functions for plotting graphs; perhaps the simplest is the plot function. The plot function requires two arguments, an expression to be graphed and a variable. For example, if you enter

plot(sin(x),x)

you will get the graph

To the right of the graph will be a panel you can use to control various aspects. By default, the graph will cover values of the variable from −10 to 10; this is of course configurable (see section 2.3, “Configuration”). To plot over a different interval you can also use a second argument of var=min..max instead of simply var. For example, if you enter

plot(sin(x),x=-pi..pi)

you will get the graph

1.6  The Help Index

You can get a list of all Xcas commands and variables using the HelpIndex menu item. This will bring up the following window:

Under Index will be a scrollable list of all the commands and variables. If you begin typing to the right of the question mark, you will be taken to the part of the list beginning with the characters you typed; for example, if you type evalf, you will get the following:

In the upper right-hand pane under Related is a list of commands related to the chosen command, below that is a list of synonyms; you can see that the approx command is the same as the evalf command. Below the line where you typed the command name is a description of the command; here you can see that evalf takes an optional second argument (brackets in the description indicate that an argument is optional) which can specify the number of digits in the approximation; for example,

evalf(pi)

will return

 3.14159

but

evalf(pi,20)

will return

 3.14159

Below the description is a line where you can enter the arguments for the command; if you enter values in these boxes then the command with the chosen arguments will be placed on the Xcas command line. At the bottom of the help window is a list of examples of the command being used; if you click on one of these examples it will appear on the Xcas command line.

As well as using the menu, you can get to the help index by using the tab key while at the Xcas command line. If you have typed the beginning of a command before using the tab key, then that beginning will be presented to you in the help index.