Assumptions on variables: about additionally assume purge supposons and or

### 4.4.8 Assumptions on variables: about additionally assume purge supposons and or

If variable is a purely symbolic variable (i.e., it doesn’t have a value or any assumptions made about it), then

abs(variable)

will return

⎪ ⎪ | variable | ⎪ ⎪

since Xcas doesn’t know what type of value the variable is supposed to represent.

The assume (or supposons) command lets you tell Xcas some properties of a variable without giving the variable a specific value. The additionally command can be used to add assumptions to a variable. The about command will display the current assumptions about a variable, and the purge command will remove all values and assumptions about a variable.

assume (or supposons) takes one mandatory argument and one optional argument:

- assumptions, statements about a variable (such as equalities and inequalities, possibly combined with and and or, and domains).
- Optionally, additionally, which indicates that the assumptions are to be added to previous assumptions, as opposed to replace them.

assume(assumptions ⟨,additionally⟩) places the assumptions on the variable. With no second argument, it will remove any previous assumptions.

- additionally takes one argument:
  assumptions as above.
- additionally(assumptions) adds the assumptions to a variable without removing assumptions.

- about takes one argument:
  var, the name of a variable.
- about(var) returns the current assumptions on the variable.

- purge takes one argument:
  var, a variable name or a sequence of variable names.
- purge(var) removes any assumptions you have made about the variable var (or about all the variables in the sequence).

For example, if you enter

assume(variable > 0)

then Xcas will assume that variable is a positive real number, and so

abs(variable)

will be evaluated to

variable

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 an 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 also assume a variable is in one of the domains real, integer, complex or rational (see Section 12.2.5).

You can check the assumptions on a variable with the about command. For the above positive integer n,
Input:

about(n)

Output:

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 (see Section 5.8.1). After the above assumption on c, 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])

Recall the purge command removes assumptions about a variable.
Input:

purge(a)

then a will no longer have any assumptions made about it.
Input:

purge(a,b)

then a and b will no longer have any assumptions made about them.