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

# IExpression

`IExpression` is an abstract class that all of the algebraic expressions in this library inherit from. Therefore, knowing this interface is imperative for a deeper understanding of the library.

#### Abstract methods

* `assign()` - assigning a value to an expression. For example, the function call `assign(x=5)` means that x will be replaced with 5 every time it appears in the expression. You can assign multiple variables at the same time. For instance: `assign(x=5, y=4)`
* `try_evaluate()` - Try to evaluate the algebraic expression to `int` or `float`. If not possible, `None` will be returned.
* `variables` - An abstract property. Each algebraic expression must have this property, that returns a collection of the variables that appear in it (a list of strings).
* `__iadd__()` - the `+=` operator
* `__isub__()` - the `-=` operator.
* `__imul__()` - the `*=` operator.
* `__ipow__()` - the `**=` operator.
* `__itruediv__()` - the `/=` operator.
* `__neg__()` - the negative sign operator. For instance: \`-x\`
* `__copy__()` - Copying the object.
* `__str__()` - A string representation of the expression.
* `simplify()` - try to simplify the expression.
* `to_dict()` - convert the object to a dictionary
* `from_dict()` (static method) - create a new expression from a matching dictionary.
* `__eq__()` - the `==` operator.
* `__ne__()` - the `!=` operator.

#### Methods

* `when()` - assign values, but on a copy of the original expression.

* `__add__()` - the `+` operator - applying `+=` on a copy of the expression.

* `__radd__()`- Same as `__add__()`

* `__sub__()`- the `-` operator - applying `-=` on a copy of the expression.

* `__mul__()`- the `*` operator - applying `*=` on a copy of the expression.

* `__rmul__()` - the `*` operator - applying `*=` on a copy of the expression.

* `__pow__()` - the `**=` operator - applying `**=` on a copy of the expression.

* `__abs__()` - the `abs()` built in method. An `Abs` object will be returned as default.

* `reinman()` - Reinman's method for finding integrals numerically. Here is the signature of the method:

  <pre class="language-python"><code class="lang-python"><strong>def reinman(self, a: float, b: float, N: int):
  </strong>                            
  </code></pre>

* `trapz()` - The Trapezoid method for finding integrals numerically. Here is the signature of the method:

  ```python
  def trapz(self, a: float, b: float, N: int):
                              
  ```

* `simpson()` - Simpson's method for finding integrals numerically. Here is the signature of the method:

  ```python
  def simpson(self, a: float, b: float, N: int):
                          
  ```

* `secant()` - The Secant method for finding a root of the expression. Here is the signature of the method:

  ```python
  def secant(self, n_0: float, n_1: float, epsilon: float = 0.00001, nmax: int = 10_000:
                              
  ```

* `bisection()` - The bisection method for finding a root of the expression. Here is the signature of the method:

  ```python
  def bisection(self, a: float, b: float, epsilon: float = 0.00001, nmax=100000):
                              
  ```

* `plot()` - Plotting an expression in 2D or 3D.

* `scatter()` - Scattering an expression in 2D or 3D.

* `to_json()` - convert the expression to a string in JSON format. This is done via the `to_dict()` method. Here is the signature of the method:

* `export_json()` - Save the expression's JSON representation in a JSON file in the specified path. Here is the signature of the method:

  ```python
  def export_json(self, path: str):
                              
  ```

* `to_Function()` - Try to convert the expression to a `Function` object. If not successful, `None` will be returned.
