> For the complete documentation index, see [llms.txt](https://jona-projects.gitbook.io/kiwicalc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jona-projects.gitbook.io/kiwicalc/symbolic-computation/abs.md).

# Abs

\*experimental feature

```python
class Abs(IExpression, IPlottable, IScatterable):
```

#### Creating a new instance

You have several ways to create a new Abs via the `__init__()` method. Here is the signature of the constructor:

```python
def __init__(self, expression: Union[IExpression, int, float], power: Union[int, float, IExpression] = 1,
                 coefficient: Union[int, float, IExpression] = 1, gen_copies=True):
                    
```

For example:

```python
x = Var('x')
print(Abs(x))
print(Abs(-x))
print(Abs(5))
print(Abs(expression=x, power=2, coefficient=3))
```

#### Addition

You can add `Abs` objects via the `+` operator. For example:

```
                        x = Var('x')
print(2*Abs(3*x) + Abs(3*x))
print(Abs(5) + Abs(-5))
                    
```

#### Subtraction

You can subtract `Abs` objects via the `-` operator. For instance:

```python
x = Var('x')
print(2 * Abs(3 * x) - Abs(3 * x))
print(Abs(5) - Abs(-5))
                    
```

#### Multiplication

You can multiply `Abs` objects via the `*` operator. For example:

```python
x = Var('x')
print(2 * Abs(3 * x) * Abs(3 * x))
print(Abs(5) * Abs(-5))
                    
```

#### Division

You can divide `Abs` objects via the `/` operator. For instance:

```python
 x = Var('x')
print(2 * Abs(3 * x) / Abs(3 * x))
print(Abs(x) / 5)
print(Abs(5) / Abs(-5))
                    
```

#### Power

You can raise Abs objects by a power via the `**` operator. For example:

```python
print(Abs(x) ** 2)
                    
```

#### Assign values

You can assign values with the `assign()` method, or with the `when()` method if you don't want to change the original object. For instance:

```python
my_abs = Abs(x)
print(my_abs.when(x=-5))
my_abs.assign(x=4)
print(my_abs)
                    
```

#### Evaluate to `int` or `float`

You can try to evaluate the `Abs` object to `int` or `float` via the `try_evaluate()` method. For example:

```python
my_abs = Abs(-5)
print(my_abs.try_evaluate())
                    
```

#### `to_lambda()`

You can generate a lambda expression from the `Abs` object via the `to_lambda()` method. For instance:

```python
my_abs = Abs(x)
print(my_abs.to_lambda())
                    
```

#### Plot

You can plot `Abs` objects via the `plot()` method. For example:

```python
x = Var('x')
my_abs = Abs(x)
my_abs.plot()
```

```python
x, y = Var('x'), Var('y')
my_abs = Abs(x + y)
my_abs.plot(step=0.3)
                    
```

#### Scatter

You can scatter `Abs` objects via the `scatter()` method. For instance:

```python
x = Var('x')
my_abs = Abs(x)
my_abs.scatter()
                    
```

```python
x, y = Var('x'), Var('y')
my_abs = Abs(x + y)
my_abs.scatter(step=0.3)
                    
```
