> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.toolkits.sympy toolkit

<a id="camel.toolkits.sympy_toolkit" />

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit" />

## SymPyToolkit

```python theme={"system"}
class SymPyToolkit(BaseToolkit):
```

A toolkit for performing symbolic computations using SymPy.
This includes methods for Algebraic manipulation calculus
and Linear Algebra.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    default_variable: str = 'x',
    timeout: Optional[float] = None
):
```

Initializes the toolkit with a default variable and logging.

**Parameters:**

* **default\_variable** (str): The default variable for operations (default: :obj:`x`)

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.simplify_expression" />

### simplify\_expression

```python theme={"system"}
def simplify_expression(self, expression: str):
```

Simplifies a mathematical expression.

**Parameters:**

* **expression** (str): The mathematical expression to simplify, provided as a string.

**Returns:**

str: JSON string containing the simplified mathematical
expression in the `"result"` field. If an error occurs,
the `"status"` field will be set to `"error"` with a
corresponding `"message"`.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.expand_expression" />

### expand\_expression

```python theme={"system"}
def expand_expression(self, expression: str):
```

Expands an algebraic expression.

**Parameters:**

* **expression** (str): The algebraic expression to expand, provided as a string.

**Returns:**

str: JSON string containing the expanded algebraic expression
in the `"result"` field. If an error occurs, the JSON
string will include an `"error"` field with the corresponding
error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.factor_expression" />

### factor\_expression

```python theme={"system"}
def factor_expression(self, expression: str):
```

Factors an algebraic expression.

**Parameters:**

* **expression** (str): The algebraic expression to factor, provided as a string.

**Returns:**

str: JSON string containing the factored algebraic expression
in the `"result"` field. If an error occurs, the JSON string
will include an `"error"` field with the corresponding error
message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.solve_linear_system" />

### solve\_linear\_system

```python theme={"system"}
def solve_linear_system(self, equations: List[str], variables: List[str]):
```

Solves a system of linear equations.

**Parameters:**

* **equations** (List\[str]): A list of strings representing the linear equations to be solved.
* **variables** (List\[str]): A list of strings representing the variables involved in the equations.

**Returns:**

str: JSON string containing the solution to the system of equations
in the `"result"` field. Each solution is represented as
a tuple of values corresponding to the variables. If an
error occurs, the JSON string will include an `"error"`
field with the corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.solve_nonlinear_system" />

### solve\_nonlinear\_system

```python theme={"system"}
def solve_nonlinear_system(self, sympy_equations: List[str], variables: List[str]):
```

Solves a system of nonlinear equations.

**Parameters:**

* **sympy\_equations** (List\[str]): A list of strings representing the nonlinear equations to be solved. The equation to solve, must be compatible with SymPy, provided as a string.
* **variables** (List\[str]): A list of strings representing the variables involved in the equations.

**Returns:**

str: JSON string containing the solutions to the system of
equations in the `"result"` field. Each solution is
represented as a tuple of values corresponding to the
variables. If an error occurs, the JSON string will
include an `"error"` field with the corresponding
error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.solve_univariate_inequality" />

### solve\_univariate\_inequality

```python theme={"system"}
def solve_univariate_inequality(self, inequality: str, variable: str):
```

Solves a single-variable inequality.

**Parameters:**

* **inequality** (str): A string representing the inequality to be solved.
* **variable** (str): The variable in the inequality.

**Returns:**

str: JSON string containing the solution to the inequality in the
`"result"` field. The solution is represented in a symbolic
format (e.g., intervals or expressions). If an error occurs,
the JSON string will include an `"error"` field with the
corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.reduce_inequalities" />

### reduce\_inequalities

```python theme={"system"}
def reduce_inequalities(self, inequalities: List[str]):
```

Reduces a system of inequalities.

**Parameters:**

* **inequalities** (List\[str]): A list of strings representing the inequalities to be reduced.

**Returns:**

str: JSON string containing the reduced system of inequalities
in the `"result"` field. The solution is represented in
a symbolic format (e.g., combined intervals or expressions).
If an error occurs, the JSON string will include an `"error"`
field with the corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.polynomial_representation" />

### polynomial\_representation

```python theme={"system"}
def polynomial_representation(self, expression: str, variable: str):
```

Represents an expression as a polynomial.

**Parameters:**

* **expression** (str): The mathematical expression to represent as a polynomial, provided as a string.
* **variable** (str): The variable with respect to which the polynomial representation will be created.

**Returns:**

str: JSON string containing the polynomial representation of the
expression in the `"result"` field. The polynomial is returned
in a symbolic format. If an error occurs, the JSON string will
include an `"error"` field with the corresponding error
message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.polynomial_degree" />

### polynomial\_degree

```python theme={"system"}
def polynomial_degree(self, expression: str, variable: str):
```

Returns the degree of a polynomial.

**Parameters:**

* **expression** (str): The polynomial expression for which the degree is to be determined, provided as a string.
* **variable** (str): The variable with respect to which the degree of the polynomial is calculated.

**Returns:**

str: JSON string containing the degree of the polynomial in the
`"result"` field. If an error occurs, the JSON string will
include an `"error"` field with the corresponding error
message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.polynomial_coefficients" />

### polynomial\_coefficients

```python theme={"system"}
def polynomial_coefficients(self, expression: str, variable: str):
```

Returns the coefficients of a polynomial.

**Parameters:**

* **expression** (str): The polynomial expression from which the coefficients are to be extracted, provided as a string.
* **variable** (str): The variable with respect to which the polynomial coefficients are determined.

**Returns:**

str: JSON string containing the list of coefficients of the
polynomial in the `"result"` field. The coefficients are
ordered from the highest degree term to the constant term.
If an error occurs, the JSON string will include an \`"error"
field with the corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.solve_equation" />

### solve\_equation

```python theme={"system"}
def solve_equation(self, sympy_equation: str, variable: Optional[str] = None):
```

Solves an equation for a specific variable.

**Parameters:**

* **sympy\_equation** (str): The equation to solve, must be compatible with SymPy, provided as a string.
* **variable** (str, optional): The variable to solve for. If not specified, the function will use the default variable.

**Returns:**

str: JSON string containing the solutions to the equation in the
`"result"` field. Each solution is represented as a string.
If an error occurs, the JSON string will include an `"error"`
field with the corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.find_roots" />

### find\_roots

```python theme={"system"}
def find_roots(self, expression: str):
```

Finds the roots of a polynomial or algebraic equation.

**Parameters:**

* **expression** (str): The polynomial or algebraic equation for which the roots are to be found, provided as a string.

**Returns:**

str: JSON string containing the roots of the expression in the
`"result"` field. The roots are represented as a list of
solutions. If an error occurs, the JSON string will include
a `"status"` field set to `"error"` and a `"message"` field
with the corresponding error description.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.differentiate" />

### differentiate

```python theme={"system"}
def differentiate(self, expression: str, variable: Optional[str] = None):
```

Differentiates an expression with respect to a variable.

**Parameters:**

* **expression** (str): The mathematical expression to differentiate, provided as a string.
* **variable** (str, optional): The variable with respect to which the differentiation is performed. If not specified, the default variable is used.

**Returns:**

str: JSON string containing the derivative of the expression in the
`"result"` field. If an error occurs, the JSON string will
include an `"error"` field with the corresponding error
message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.integrate" />

### integrate

```python theme={"system"}
def integrate(self, expression: str, variable: Optional[str] = None):
```

Integrates an expression with respect to a variable.

**Parameters:**

* **expression** (str): The mathematical expression to integrate, provided as a string.
* **variable** (str, optional): The variable with respect to which the integration is performed. If not specified, the default variable is used.

**Returns:**

str: JSON string containing the integral of the expression in the
`"result"` field. If an error occurs, the JSON string will
include an `"error"` field with the corresponding error
message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.definite_integral" />

### definite\_integral

```python theme={"system"}
def definite_integral(
    self,
    expression: str,
    variable: str,
    lower: float,
    upper: float
):
```

Computes the definite integral of an expression within given
bounds.

**Parameters:**

* **expression** (str): The mathematical expression to integrate, provided as a string.
* **variable** (str): The variable with respect to which the definite integration is performed.
* **lower** (float): The lower limit of the integration.
* **upper** (float): The upper limit of the integration.

**Returns:**

str: JSON string containing the result of the definite integral
in the `"result"` field. If an error occurs, the JSON string
will include an `"error"` field with the corresponding error
message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.series_expansion" />

### series\_expansion

```python theme={"system"}
def series_expansion(
    self,
    expression: str,
    variable: str,
    point: float,
    order: int
):
```

Expands an expression into a Taylor series around a given point up
to a specified order.

**Parameters:**

* **expression** (str): The mathematical expression to expand, provided as a string.
* **variable** (str): The variable with respect to which the series expansion is performed.
* **point** (float): The point around which the Taylor series is expanded.
* **order** (int): The order up to which the series expansion is computed.

**Returns:**

str: JSON string containing the Taylor series expansion of the
expression in the `"result"` field. If an error occurs,
the JSON string will include an `"error"` field with the
corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.compute_limit" />

### compute\_limit

```python theme={"system"}
def compute_limit(
    self,
    expression: str,
    variable: str,
    point: float
):
```

Computes the limit of an expression as a variable approaches
a point.

**Parameters:**

* **expression** (str): The mathematical expression for which the limit is to be computed, provided as a string.
* **variable** (str): The variable with respect to which the limit is computed.
* **point** (float): The point that the variable approaches.

**Returns:**

str: JSON string containing the computed limit of the expression
in the `"result"` field. If an error occurs, the JSON string
will include an `"error"` field with the corresponding error
message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.find_critical_points" />

### find\_critical\_points

```python theme={"system"}
def find_critical_points(self, expression: str, variable: str):
```

Finds the critical points of an expression by setting its
derivative to zero.

**Parameters:**

* **expression** (str): The mathematical expression for which critical points are to be found, provided as a string.
* **variable** (str): The variable with respect to which the critical points are determined.

**Returns:**

str: JSON string containing the critical points of the expression
in the `"result"` field. The critical points are returned as a
list of values corresponding to the variable. If an error
occurs, the JSON string will include an `"error"` field with
the corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.check_continuity" />

### check\_continuity

```python theme={"system"}
def check_continuity(
    self,
    expression: str,
    variable: str,
    point: float
):
```

Checks if an expression is continuous at a given point.

**Parameters:**

* **expression** (str): The mathematical expression to check for continuity, provided as a string.
* **variable** (str): The variable with respect to which continuity is checked.
* **point** (float): The point at which the continuity of the expression is checked.

**Returns:**

str: JSON string containing the result of the continuity check in
the `"result"` field. The result will be `"True"` if the
expression is continuous at the given point, otherwise
`"False"`. If an error occurs, the JSON string will include
an `"error"` field with the corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.compute_determinant" />

### compute\_determinant

```python theme={"system"}
def compute_determinant(self, matrix: List[List[float]]):
```

Computes the determinant of a matrix.

**Parameters:**

* **matrix** (List\[List\[float]]): A two-dimensional list representing the matrix for which the determinant is to be computed.

**Returns:**

str: JSON string containing the determinant of the matrix in the
`"result"` field. If an error occurs, the JSON string will
include an `"error"` field with the corresponding error
message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.compute_inverse" />

### compute\_inverse

```python theme={"system"}
def compute_inverse(self, matrix: List[List[float]]):
```

Computes the inverse of a matrix.

**Parameters:**

* **matrix** (List\[List\[float]]): A two-dimensional list representing the matrix for which the inverse is to be computed.

**Returns:**

str: JSON string containing the inverse of the matrix in the
`"result"` field. The inverse is represented in a symbolic
matrix format. If an error occurs, the JSON string will
include an `"error"` field with the corresponding error
message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.compute_eigenvalues" />

### compute\_eigenvalues

```python theme={"system"}
def compute_eigenvalues(self, matrix: List[List[float]]):
```

Computes the eigenvalues of a matrix.

**Parameters:**

* **matrix** (List\[List\[float]]): A two-dimensional list representing the matrix for which the eigenvalues are to be computed.

**Returns:**

str: JSON string containing the eigenvalues of the matrix in the
`"result"` field. The eigenvalues are represented as a
dictionary where keys are the eigenvalues (as strings) and
values are their multiplicities (as strings). If an error
occurs, the JSON string will include an `"error"` field
with the corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.compute_eigenvectors" />

### compute\_eigenvectors

```python theme={"system"}
def compute_eigenvectors(self, matrix: List[List[float]]):
```

Computes the eigenvectors of a matrix.

**Parameters:**

* **matrix** (List\[List\[float]]): A two-dimensional list representing the matrix for which the eigenvectors are to be computed.

**Returns:**

str: JSON string containing the eigenvectors of the matrix in the
`"result"` field. Each eigenvalue is represented as a
dictionary with the following keys:

* `"eigenvalue"`: The eigenvalue (as a string).
* `"multiplicity"`: The multiplicity of the eigenvalue
  (as an integer).
* `"eigenvectors"`: A list of eigenvectors
  (each represented as a string).

If an error occurs, the JSON string will include an `"error"`
field with the corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.compute_nullspace" />

### compute\_nullspace

```python theme={"system"}
def compute_nullspace(self, matrix: List[List[float]]):
```

Computes the null space of a matrix.

**Parameters:**

* **matrix** (List\[List\[float]]): A two-dimensional list representing the matrix for which the null space is to be computed.

**Returns:**

str: JSON string containing the null space of the matrix in the
`"result"` field. The null space is represented as a list of
basis vectors, where each vector is given as a string in
symbolic format. If an error occurs, the JSON string will
include an `"error"` field with the corresponding error
message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.compute_rank" />

### compute\_rank

```python theme={"system"}
def compute_rank(self, matrix: List[List[float]]):
```

Computes the rank of a matrix.

**Parameters:**

* **matrix** (List\[List\[float]]): A two-dimensional list representing the matrix for which the rank is to be computed.

**Returns:**

str: JSON string containing the rank of the matrix in the
`"result"` field. The rank is represented as an integer.
If an error occurs,the JSON string will include an
`"error"` field with the corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.compute_inner_product" />

### compute\_inner\_product

```python theme={"system"}
def compute_inner_product(self, vector1: List[float], vector2: List[float]):
```

Computes the inner (dot) product of two vectors.

**Parameters:**

* **vector1** (List\[float]): The first vector as a list of floats.
* **vector2** (List\[float]): The second vector as a list of floats.

**Returns:**

str: JSON string containing the inner product in the `"result"`
field. If an error occurs, the JSON string will include an
`"error"` field with the corresponding error message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.handle_exception" />

### handle\_exception

```python theme={"system"}
def handle_exception(self, func_name: str, error: Exception):
```

Handles exceptions by logging and returning error details.

**Parameters:**

* **func\_name** (str): The name of the function where the exception occurred.
* **error** (Exception): The exception object containing details about the error.

**Returns:**

str: JSON string containing the error details.
The JSON includes:

* `"status"`: Always set to `"error"`.
* `"message"`: A string representation of the
  exception message.

<a id="camel.toolkits.sympy_toolkit.SymPyToolkit.get_tools" />

### get\_tools

```python theme={"system"}
def get_tools(self):
```

**Returns:**

List\[FunctionTool]: A list of `FunctionTool` objects representing
the toolkit's methods, making them accessible to the agent.
