py-num-methods


Namepy-num-methods JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryNumerical Methods and Analysis Library in Python
upload_time2024-03-28 19:06:11
maintainerNone
docs_urlNone
authorJaidevSK
requires_pythonNone
licenseMIT
keywords numerical methods
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            py_num_methods: This is the module for the Numerical Methods such as approximations, equation solving, solving sets of linear equations, interpolations, numerical integration, numerical differentiation, and ODE solving.


# Approximations:

### Euler's Method

    import py_num_methods.approximations as pynma
    x, y = pynma.euler_method(f, x0, y0, h, n)
        
    '''
    Parameters:
        - f: The derivative function of the ODE.
        - x0: The initial x value.
        - y0: The initial y value.
        - h: The step size.
        - n: The number of iterations.
        
    Returns:
        - x: The array of x values.
        - y: The array of y values.
    '''

# Equation Solving:

    import py_num_methods.eqn_solver as pynm_es

### Graphical Solver:

    pynm_es.solve_equation_graphically(equation, x_range, y_range)
    
    '''
    Parameters:
	- equation: function
	- x_range: Tuple
	- y_range: Tuple

    Returns:
	- None
	- Plots the graph
    '''
### Bisection Method:

    ret = pynm_es.bisection_method(f, a, b, tol)
    
    '''
    Parameters:
        - f: The function for which we want to find the root.
        - a: The lower bound of the interval.
        - b: The upper bound of the interval.
        - tol: The tolerance level for the root.
        
    Returns:
        - The approximate root of the function within the specified tolerance level.
    '''
### False Position Method:

    ret = pynm_es.false_position_method(f, a, b, tol, max_iter)

    '''
    Parameters:
        - f: The function for which we want to find the root.
        - a and b: The initial interval endpoints.
        - tol: The tolerance level for convergence.
        - max_iter: The maximum number of iterations allowed.
    Returns:
        - The approximate root of the function.
    '''
### Fixed Point Iterations:

    ret = pynm_es.fixed_point_iteration(f, initial_guess, tolerance, max_iterations)

    '''
    Parameters:
        - f: The function for which we want to find the root.
        - initial_guess: The initial guess value.
        - tolerance: The tolerance level for convergence.
        - max_iterations: The maximum number of iterations allowed.

    Returns:
        - The approximate root of the function.
    '''
# Simultaneous Linear Equation Solver:

    import py_num_methods.sim_lin_eqn_solve as pynmsles

### Gaussian Elimination:

    x = pynmsles.gaussian_elimination(A, b)

    '''
    Parameters:
        - A: The A (coefficient) matrix in Ax=b
        - b: The b (constant) matrix in Ax=b

    Returns:
        - x: Solution
    '''
### LU Decomposition:

    x = pynmsles.lu_decomposition(A, b)

    '''
    Parameters:
        - A: The A (coefficient) matrix in Ax=b
        - b: The b (constant) matrix in Ax=b

    Returns:
        - x: Solution
    '''
### Tri Diagonal Matrix Algorithm:

    x = pynmsles.solve_tdma(A, b)

    '''
    Parameters:
        - A: The A (coefficient) matrix in Ax=b
        - b: The b (constant) matrix in Ax=b

    Returns:
        - x: Solution
    '''
### Gauss Seidel:

    x = pynmsles.gauss_seidel(A, b, x0, max_iterations=100, tolerance=1e-6)

    '''
    Parameters:
            - A: The A (coefficient) matrix in Ax=b
            - b: The b (constant) matrix in Ax=b
        - x0: Initial guess array
        - max_iterations: Max number of iterations
        - tolerance: Permissible tolerance in relative error

    Returns:
        - x: Solution
    '''
# Interpolations:

    import py_num_methods.interpolations as pynmi

### Quadratic Interpolations:

    y = pynmi.quadratic_interpolation(x, x0, x1, x2, y0, y1, y2)
    '''
    Parameters:
        - x : The point at which to estimate the value.
        - x0, x1, x2 : The x-coordinates of the three data points.
        - y0, y1, y2 : The y-coordinates of the three data points.

    Returns:
    - y = estimated value at point x.
    '''
### Lagrange Interpolations:

    x = pynmi.lagrange_interpolation(x, y, xi)
    '''
    Parameters:
        - x, y : Arrays of data points
    - xi : Value at which we want to approximate the function

    Returns:
    - yi = interpolated value at point xi
    '''
# Numerical Integration:

    import py_num_methods.numerical_integration as pynmni

### Trapezoidal Integration:

    val = pynmni.trapezoidal_integration(f, a, b, n)
    '''
    Parameters:
        - f: The function to be integrated.
        - a: The lower limit of integration.
        - b: The upper limit of integration.
        - n: The number of subintervals to divide the integration interval into.
        
    Returns:
        - val = The approximate value of the integral.
    '''
### Simpsons 1/3 method:

    val = pynmni.simpsons_13(f, a, b, n)
    '''
    Parameters:
        - f: The function to be integrated.
        - a: The lower limit of integration.
        - b: The upper limit of integration.
        - n: The number of subintervals.
        
    Returns:
        - val = The approximate value of the definite integral.
    '''
### Simpsons 3/8 method:

    val = pynmni.simpsons_38(f, a, b, n)
    '''
    Parameters:
        - f: The function to be integrated.
        - a: The lower limit of integration.
        - b: The upper limit of integration.
        - n: The number of subintervals.
        
    Returns:
        - val = The approximate value of the definite integral.
    '''
# Numerical Differentiation

    import py_num_methods.numerical_differentiation as pynmnd

    val = pynmnd.numerical_differentiation(f, x, h, method)
    '''	
    Parameters:
    - f: Function
    - x: x values for finding slope at
    - h: The value of interval size
    - method: "central", "backward" and "forward" based on type of differentiation

    Returns:
    val = The approximate value of differentiated function at x
    '''
# ODE Solver

    import py_num_methods.ODE_solver as pynmode

### Predictor Corrector Method:

    t, y = pynmode.predictor_corrector(f, y0, t0, tn, h)
    '''
    Parameters:
        - f: The function defining the ODE dy/dt = f(t, y).
        - y0: The initial condition y(t0) = y0.
        - t0: The initial time.
        - tn: The final time.
        - h: The time step size.

    Returns:
        - t: An array of time values.
        - y: An array of corresponding solution values.
    '''
### Second Order Runge Kutta:

    t, y = pynmode.runge_kutta_2(f, t0, y0, h, n)
    '''
        Parameters:
        - f: The function defining the ODE dy/dt = f(t, y).
        - t0: The initial value of the independent variable.
        - y0: The initial value of the dependent variable.
        - h: The step size.
        - n: The number of steps.

        Returns:
        - t: The array of time values.
        - y: The array of solution values.
    '''

### Fourth Order Runge Kutta:

    t, y = pynmode.runge_kutta_4(f, t0, y0, h, n)
    '''
        Parameters:
        - f: The function defining the ODE dy/dt = f(t, y).
        - t0: The initial value of the independent variable.
        - y0: The initial value of the dependent variable.
        - h: The step size.
        - n: The number of steps.

        Returns:
        - t: The array of time values.
        - y: The array of solution values.
    '''
           


Change Log
==========

0.0.1 (10/12/2023)
-------------------
- First Release

0.1.0 (29/03/24)
-------------------
- Second Release

0.1.1 (29/03/24)
-------------------
- First Update

0.1.2 (29/03/24)
-------------------
- Second Update

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "py-num-methods",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "Numerical Methods",
    "author": "JaidevSK",
    "author_email": "jaidevkhalane@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/5c/62/99c94a561c1b3b0cbd10aacfc93a7569cc44c00c11666f52e9bad17f0f6c/py_num_methods-0.1.2.tar.gz",
    "platform": null,
    "description": "py_num_methods: This is the module for the Numerical Methods such as approximations, equation solving, solving sets of linear equations, interpolations, numerical integration, numerical differentiation, and ODE solving.\r\n\r\n\r\n# Approximations:\r\n\r\n### Euler's Method\r\n\r\n    import py_num_methods.approximations as pynma\r\n    x, y = pynma.euler_method(f, x0, y0, h, n)\r\n        \r\n    '''\r\n    Parameters:\r\n        - f: The derivative function of the ODE.\r\n        - x0: The initial x value.\r\n        - y0: The initial y value.\r\n        - h: The step size.\r\n        - n: The number of iterations.\r\n        \r\n    Returns:\r\n        - x: The array of x values.\r\n        - y: The array of y values.\r\n    '''\r\n\r\n# Equation Solving:\r\n\r\n    import py_num_methods.eqn_solver as pynm_es\r\n\r\n### Graphical Solver:\r\n\r\n    pynm_es.solve_equation_graphically(equation, x_range, y_range)\r\n    \r\n    '''\r\n    Parameters:\r\n\t- equation: function\r\n\t- x_range: Tuple\r\n\t- y_range: Tuple\r\n\r\n    Returns:\r\n\t- None\r\n\t- Plots the graph\r\n    '''\r\n### Bisection Method:\r\n\r\n    ret = pynm_es.bisection_method(f, a, b, tol)\r\n    \r\n    '''\r\n    Parameters:\r\n        - f: The function for which we want to find the root.\r\n        - a: The lower bound of the interval.\r\n        - b: The upper bound of the interval.\r\n        - tol: The tolerance level for the root.\r\n        \r\n    Returns:\r\n        - The approximate root of the function within the specified tolerance level.\r\n    '''\r\n### False Position Method:\r\n\r\n    ret = pynm_es.false_position_method(f, a, b, tol, max_iter)\r\n\r\n    '''\r\n    Parameters:\r\n        - f: The function for which we want to find the root.\r\n        - a and b: The initial interval endpoints.\r\n        - tol: The tolerance level for convergence.\r\n        - max_iter: The maximum number of iterations allowed.\r\n    Returns:\r\n        - The approximate root of the function.\r\n    '''\r\n### Fixed Point Iterations:\r\n\r\n    ret = pynm_es.fixed_point_iteration(f, initial_guess, tolerance, max_iterations)\r\n\r\n    '''\r\n    Parameters:\r\n        - f: The function for which we want to find the root.\r\n        - initial_guess: The initial guess value.\r\n        - tolerance: The tolerance level for convergence.\r\n        - max_iterations: The maximum number of iterations allowed.\r\n\r\n    Returns:\r\n        - The approximate root of the function.\r\n    '''\r\n# Simultaneous Linear Equation Solver:\r\n\r\n    import py_num_methods.sim_lin_eqn_solve as pynmsles\r\n\r\n### Gaussian Elimination:\r\n\r\n    x = pynmsles.gaussian_elimination(A, b)\r\n\r\n    '''\r\n    Parameters:\r\n        - A: The A (coefficient) matrix in Ax=b\r\n        - b: The b (constant) matrix in Ax=b\r\n\r\n    Returns:\r\n        - x: Solution\r\n    '''\r\n### LU Decomposition:\r\n\r\n    x = pynmsles.lu_decomposition(A, b)\r\n\r\n    '''\r\n    Parameters:\r\n        - A: The A (coefficient) matrix in Ax=b\r\n        - b: The b (constant) matrix in Ax=b\r\n\r\n    Returns:\r\n        - x: Solution\r\n    '''\r\n### Tri Diagonal Matrix Algorithm:\r\n\r\n    x = pynmsles.solve_tdma(A, b)\r\n\r\n    '''\r\n    Parameters:\r\n        - A: The A (coefficient) matrix in Ax=b\r\n        - b: The b (constant) matrix in Ax=b\r\n\r\n    Returns:\r\n        - x: Solution\r\n    '''\r\n### Gauss Seidel:\r\n\r\n    x = pynmsles.gauss_seidel(A, b, x0, max_iterations=100, tolerance=1e-6)\r\n\r\n    '''\r\n    Parameters:\r\n            - A: The A (coefficient) matrix in Ax=b\r\n            - b: The b (constant) matrix in Ax=b\r\n        - x0: Initial guess array\r\n        - max_iterations: Max number of iterations\r\n        - tolerance: Permissible tolerance in relative error\r\n\r\n    Returns:\r\n        - x: Solution\r\n    '''\r\n# Interpolations:\r\n\r\n    import py_num_methods.interpolations as pynmi\r\n\r\n### Quadratic Interpolations:\r\n\r\n    y = pynmi.quadratic_interpolation(x, x0, x1, x2, y0, y1, y2)\r\n    '''\r\n    Parameters:\r\n        - x : The point at which to estimate the value.\r\n        - x0, x1, x2 : The x-coordinates of the three data points.\r\n        - y0, y1, y2 : The y-coordinates of the three data points.\r\n\r\n    Returns:\r\n    - y = estimated value at point x.\r\n    '''\r\n### Lagrange Interpolations:\r\n\r\n    x = pynmi.lagrange_interpolation(x, y, xi)\r\n    '''\r\n    Parameters:\r\n        - x, y : Arrays of data points\r\n    - xi : Value at which we want to approximate the function\r\n\r\n    Returns:\r\n    - yi = interpolated value at point xi\r\n    '''\r\n# Numerical Integration:\r\n\r\n    import py_num_methods.numerical_integration as pynmni\r\n\r\n### Trapezoidal Integration:\r\n\r\n    val = pynmni.trapezoidal_integration(f, a, b, n)\r\n    '''\r\n    Parameters:\r\n        - f: The function to be integrated.\r\n        - a: The lower limit of integration.\r\n        - b: The upper limit of integration.\r\n        - n: The number of subintervals to divide the integration interval into.\r\n        \r\n    Returns:\r\n        - val = The approximate value of the integral.\r\n    '''\r\n### Simpsons 1/3 method:\r\n\r\n    val = pynmni.simpsons_13(f, a, b, n)\r\n    '''\r\n    Parameters:\r\n        - f: The function to be integrated.\r\n        - a: The lower limit of integration.\r\n        - b: The upper limit of integration.\r\n        - n: The number of subintervals.\r\n        \r\n    Returns:\r\n        - val = The approximate value of the definite integral.\r\n    '''\r\n### Simpsons 3/8 method:\r\n\r\n    val = pynmni.simpsons_38(f, a, b, n)\r\n    '''\r\n    Parameters:\r\n        - f: The function to be integrated.\r\n        - a: The lower limit of integration.\r\n        - b: The upper limit of integration.\r\n        - n: The number of subintervals.\r\n        \r\n    Returns:\r\n        - val = The approximate value of the definite integral.\r\n    '''\r\n# Numerical Differentiation\r\n\r\n    import py_num_methods.numerical_differentiation as pynmnd\r\n\r\n    val = pynmnd.numerical_differentiation(f, x, h, method)\r\n    '''\t\r\n    Parameters:\r\n    - f: Function\r\n    - x: x values for finding slope at\r\n    - h: The value of interval size\r\n    - method: \"central\", \"backward\" and \"forward\" based on type of differentiation\r\n\r\n    Returns:\r\n    val = The approximate value of differentiated function at x\r\n    '''\r\n# ODE Solver\r\n\r\n    import py_num_methods.ODE_solver as pynmode\r\n\r\n### Predictor Corrector Method:\r\n\r\n    t, y = pynmode.predictor_corrector(f, y0, t0, tn, h)\r\n    '''\r\n    Parameters:\r\n        - f: The function defining the ODE dy/dt = f(t, y).\r\n        - y0: The initial condition y(t0) = y0.\r\n        - t0: The initial time.\r\n        - tn: The final time.\r\n        - h: The time step size.\r\n\r\n    Returns:\r\n        - t: An array of time values.\r\n        - y: An array of corresponding solution values.\r\n    '''\r\n### Second Order Runge Kutta:\r\n\r\n    t, y = pynmode.runge_kutta_2(f, t0, y0, h, n)\r\n    '''\r\n        Parameters:\r\n        - f: The function defining the ODE dy/dt = f(t, y).\r\n        - t0: The initial value of the independent variable.\r\n        - y0: The initial value of the dependent variable.\r\n        - h: The step size.\r\n        - n: The number of steps.\r\n\r\n        Returns:\r\n        - t: The array of time values.\r\n        - y: The array of solution values.\r\n    '''\r\n\r\n### Fourth Order Runge Kutta:\r\n\r\n    t, y = pynmode.runge_kutta_4(f, t0, y0, h, n)\r\n    '''\r\n        Parameters:\r\n        - f: The function defining the ODE dy/dt = f(t, y).\r\n        - t0: The initial value of the independent variable.\r\n        - y0: The initial value of the dependent variable.\r\n        - h: The step size.\r\n        - n: The number of steps.\r\n\r\n        Returns:\r\n        - t: The array of time values.\r\n        - y: The array of solution values.\r\n    '''\r\n           \r\n\r\n\r\nChange Log\r\n==========\r\n\r\n0.0.1 (10/12/2023)\r\n-------------------\r\n- First Release\r\n\r\n0.1.0 (29/03/24)\r\n-------------------\r\n- Second Release\r\n\r\n0.1.1 (29/03/24)\r\n-------------------\r\n- First Update\r\n\r\n0.1.2 (29/03/24)\r\n-------------------\r\n- Second Update\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Numerical Methods and Analysis Library in Python",
    "version": "0.1.2",
    "project_urls": null,
    "split_keywords": [
        "numerical",
        "methods"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c6299c94a561c1b3b0cbd10aacfc93a7569cc44c00c11666f52e9bad17f0f6c",
                "md5": "96cc525d86e84e83c7ee12724a470c8b",
                "sha256": "275c491c9b68bb592242e0131caee7d06edc3f4c4520dba9a6e5ba345e26cd47"
            },
            "downloads": -1,
            "filename": "py_num_methods-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "96cc525d86e84e83c7ee12724a470c8b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6701,
            "upload_time": "2024-03-28T19:06:11",
            "upload_time_iso_8601": "2024-03-28T19:06:11.613089Z",
            "url": "https://files.pythonhosted.org/packages/5c/62/99c94a561c1b3b0cbd10aacfc93a7569cc44c00c11666f52e9bad17f0f6c/py_num_methods-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-28 19:06:11",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "py-num-methods"
}
        
Elapsed time: 0.20319s