> 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/var.md).

# Var

The var class enables you to define variables and then use arithmetic operations on them without ever changing the original variable. `Var` inherits from `Mono`, and in order to use it, you must import it first:&#x20;

```python
from kiwicalc import Var
```

#### Creating a new variable

Creating a new Var object is extremely simple, and requires only the name of the variable. For example

```python
x = Var('x')
y = Var('y')
z = Var('z')
```

#### Calculations with Var

Since `Var` inherits from `Mono`, You can use the \`+\` , \`-\` , \* , \`/\` , \*\* operators for calculating algebraic expressions, similar to how it's done in the Mono class.

**Example 2 - Basic calculations with Var**

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

# output:

# x^2-10x+25
# x^2-(y^2)
# x^2+2x*y+y^2
# x^3+3x^2*y+15x^2+3x*y^2+30x*y+75x+y^3+15y^2+75y+125
                        

```

While here the examples show the use of 2 variables\_dict (x and y), you can use as many variables\_dict as you'd like. That way you can simplify sophisticated polynomials in an instant, which could have taken hours by hand.

**Derivatives and Integrals**

You can use `Var` to compute the polynomial's derivatives and integrals, (it evaluates to `Mono` or `Poly` object).

Note: This feature is only possible with one variable. For example:

```
                        print((3*x**2).derivative())
print((6*x).integral())

# output:
# 6x
# 3x^2

```

#### Checking if two expressions are equal

You can equate algebraic expressions using the '==' operator, or the method `__eq__()`. You could also check if two algebraic expressions aren't equal, using the '!=' operator or the `__ne__()` method.

**For example:**

```python
print(3*y == 2*x+6)
print((2*x + 2*y) / 2 == y + (2* x**2) / (2*x))
print(2 * x + 5 != 3*y*x**2 - 4)

# output:
# False
# True
# True

                    
```

***
