### 4.5.6 Assumptions on variables

If you enter

> abs(var)

the Xcas will return it unevaluated, since Xcas doesn’t know what type of value the variable is supposed to represent.

The assume (or supposons) command will let you tell Xcas some properties of a variable without giving the variable a specific value. For example, if you enter

> assume(var > 0)

then Xcas will assume that var is a positive real number, and so for example

> abs(var)

will be evaluated to

> var

You can put one or more conditions in the assume command by combining them with and and or. For example, if you want the variable a to be in [2,4) ∪ (6,∞), you can enter

> assume((a >= 2 and a < 4) or a > 6)

If a variable has attached assumptions, then making another assumption with assume will remove the original assumptions. To add extra assumptions, you can either use the additionally command or give assume a second argument of additionally. If you assume that b > 0 with

> assume(b > 0)

and you want to add the condition that b < 1, you can either enter

> assume(b < 1, additionally)

or

> additionally(b < 1)

As well as equalities and inequalities, you can make assumptions about the domain of a variable. If you want n to represent a positive integer, for example, you can enter

> assume(n, integer)

If you want n to be a positive integer, you can add the condition

> additionally(n > 0)

You can use the about command to check the assumptions on a variable; for the above positive integer n, if you enter

> about(n)

you will get

> assume[integer,[line[0,+infinity]],[0]]

The first element tells you that n is an integer, the second element tells you that n is between 0 and +infinity, and the third element tells you that the value 0 is excluded.

If you assume that a variable is equal to a specific value, such as

> assume(c = 2)

then by default the variable c will remain unevaluated in later levels. If you want an expression involving c to be evaluated, you would need to put the expression inside the evalf command; if you enter

> evalf(c^2 + 3)

then you will get

> 7.0

Right below the assume(c = 2) command line there will be a slider, namely arrows pointing left and right with the value 2 between them. These can be used to change the values of c. If you click on the right arrow, the assume(c = 2) command will transform to

> assume(c=[2.2,-10.0,10.0,0.0])

and the value between the arrows will be 2.2. Also, any later levels where the variable c is evaluated will be re-evaluated with the value of c now 2.2. The output to evalf(c^2 + 3 will become

> 7.84

The -10.0 and 10.0 in the assume line represent the smallest and largest values that c can become using the sliders. You can set them yourself in the assume command, as well as the increment that the value will change; if you want c to start with the value 5 and vary between 2 and 8 in increments of 0.05, then you can enter

> assume(c = [5,2,8,0.05])

You can remove any assumptions you have made about a variable with the purge command; if you enter

> purge(a)

then a will no longer have any assumptions made about it. You can remove assumptions from more than one variable at a time;

> purge(a,b)

will remove any assumptions about a and b.