Skip to main content

A library to simplify mathematical computations.

Project description

stdmathlib

A Python library to simplify mathematical computations.

Installation

pip install stdmathlib

Functions

integrate_expression

Integrates a mathematical expression with respect to a variable.

Parameters:

  • expression_str (str): The mathematical expression as a string.
  • var (str): The variable to integrate with respect to (default is 'x').
  • lower_limit (float, optional): The lower limit of integration.
  • upper_limit (float, optional): The upper limit of integration.

Returns:

  • integral_expr: The symbolic integral expression (indefinite integral).
  • integral_value (optional): The numerical value of the definite integral.

Example Usage:

from stdmathlib import integrate_expression

# Indefinite integral
integral_expr = integrate_expression('x**2')
print(f"Indefinite integral: {integral_expr} + C")  # Output: x**3/3 + C

# Definite integral from x=0 to x=2
integral_expr, integral_value = integrate_expression('x**2', lower_limit=0, upper_limit=2)
print(f"Indefinite integral: {integral_expr} + C")          # Output: x**3/3 + C
print(f"Definite integral from 0 to 2: {integral_value}")  # Output: 2.66666666666667

derivative

Differentiates a mathematical expression with respect to a variable.

Parameters:

  • expression_str (str): The mathematical expression as a string.
  • var (str): The variable to differentiate with respect to (default is 'x').
  • eval_point (float, optional): The point at which to evaluate the derivative.

Returns:

  • derivative_expr: The symbolic derivative expression.
  • derivative_value (optional): The numerical value of the derivative at eval_point.

Example Usage:

from stdmathlib import derivative

# Differentiate symbolically
derivative = derivative('x**2 + 3*x + 2')
print(derivative)  # Output: 2*x + 3

# Differentiate and evaluate at x = 2
derivative_expr, derivative_value = derivative('x**2 + 3*x + 2', eval_point=2)
print(derivative_expr)      # Output: 2*x + 3
print(derivative_value)     # Output: 7

partial_derivative_expression

Computes the partial derivative of a multivariable function with respect to specified variables.

Parameters:

  • expression_str (str): The multivariable function as a string.
  • variables (list of str): List of variable names in the function.
  • differentiation_vars (list of str): List of variables to differentiate with respect to.
  • eval_points (dict, optional): Dictionary of variable values for evaluation.

Returns:

  • derivative_expr: The symbolic partial derivative expression.
  • derivative_value (optional): The numerical value of the derivative at eval_points.

Example Usage:

from stdmathlib import partial_derivative_expression

# Compute ?f/?x
expression = 'x**2 * y + y**3'
variables = ['x', 'y']
differentiation_vars = ['x']
partial_derivative = partial_derivative_expression(expression, variables, differentiation_vars)
print(partial_derivative)  # Output: 2*x*y

Functions

plot

Plots a mathematical expression using matplotlib.

Parameters:

  • expression_str (str): The mathematical expression as a string, e.g., 'sin(x)'.
  • var (str): The variable in the expression (default is 'x').
  • range_start (float): The start of the range for the variable (default is -10).
  • range_end (float): The end of the range for the variable (default is 10).
  • num_points (int): The number of points to compute for plotting (default is 1000).

Returns:

  • None: Displays the plot.

Example Usage:

from stdmathliblib import plot
import numpy as np

# Plot y = sin(x) from -2? to 2?
plot('sin(x)', range_start=-2*np.pi, range_end=2*np.pi)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stdmathlib-0.1.8.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stdmathlib-0.1.8-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file stdmathlib-0.1.8.tar.gz.

File metadata

  • Download URL: stdmathlib-0.1.8.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.12.7

File hashes

Hashes for stdmathlib-0.1.8.tar.gz
Algorithm Hash digest
SHA256 40562b47528868507854f26af916fa4e26226e34e6c00df2614ffe4d2ef73097
MD5 4a1593b0798140f6d2c11c5e7532ec6a
BLAKE2b-256 e8c596bac25cde5198f08c1a71444b5a35b0b8706df59fbcaa1ec6effcb6ded3

See more details on using hashes here.

File details

Details for the file stdmathlib-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: stdmathlib-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.12.7

File hashes

Hashes for stdmathlib-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 157a150d26774ee5a76bf99973930e97107307a08b8d885cb7a51882a72d967c
MD5 17e62ee2b6e27e6314fd2af190131f5f
BLAKE2b-256 0d41a3c5e6d27796eccd46e29365cb4fab19e0fe2d90c299210f4fe601ceeada

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page