1 | initial version |

You have to keep in mind that in SageMath, symbolic variables have their own type:

```
sage: type(x)
<class 'sage.symbolic.expression.Expression'>
```

What you can do is to specify some domain for a symbolic variable; by default the domain is assumed to be the set of complex numbers, by you can restrict to real numbers by declaring

```
sage: x = var('x', domain='real')
```

This is taken into account in simplifications:

```
sage: sqrt(x^2).simplify()
abs(x)
sage: x = var('x', domain='complex') # back to the default
sage: sqrt(x^2).simplify()
sqrt(x^2)
```

2 | No.2 Revision |

You have to keep in mind that in SageMath, symbolic variables have their own type:

```
sage: type(x)
<class 'sage.symbolic.expression.Expression'>
```

What you can do is to specify some domain for a symbolic variable; by default the domain is assumed to be the set of complex numbers, by you can restrict to real numbers by declaring

```
sage: x = var('x', domain='real')
```

This is taken into account in simplifications:

`sage: `~~sqrt(x^2).simplify()
~~sqrt(x^2)
abs(x)
sage: x = var('x', domain='complex') # back to the default
sage: ~~sqrt(x^2).simplify()
~~sqrt(x^2)
sqrt(x^2)

Another option is

```
sage: x = var('x', domain='positive')
sage: sqrt(x^2)
x
```

3 | No.3 Revision |

You have to keep in mind that in SageMath, symbolic variables have their own type:

```
sage: type(x)
<class 'sage.symbolic.expression.Expression'>
```

What you can do is to specify some domain for a symbolic variable; by default the domain is assumed to be the set of complex numbers, by you can restrict to real numbers by declaring

```
sage: x = var('x', domain='real')
```

This is taken into account in simplifications:

```
sage: sqrt(x^2)
abs(x)
sage: x = var('x', domain='complex') # back to the default
sage: sqrt(x^2)
sqrt(x^2)
```

~~Another option is ~~Other options are:

```
sage: x = var('x', domain='positive')
sage: sqrt(x^2)
x
sage: x = var('x', domain='integer')
sage: cos(x*pi).simplify_full()
(-1)^x
```

4 | No.4 Revision |

You have to keep in mind that in SageMath, symbolic variables have their own type:

```
sage: type(x)
<class 'sage.symbolic.expression.Expression'>
```

What you can do is to specify some domain for a symbolic variable; by default the domain is assumed to be the set of complex numbers, ~~by ~~but you can restrict to real numbers by declaring

```
sage: x = var('x', domain='real')
```

This is taken into account in simplifications:

```
sage: sqrt(x^2)
abs(x)
sage: x = var('x', domain='complex') # back to the default
sage: sqrt(x^2)
sqrt(x^2)
```

Other options are:

```
sage: x = var('x', domain='positive')
sage: sqrt(x^2)
x
sage: x = var('x', domain='integer')
sage: cos(x*pi).simplify_full()
(-1)^x
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.