403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/scipy/optimize/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/scipy/optimize/__pycache__/_root_scalar.cpython-311.pyc
�

d�c!H���dZddlZddlmZdgZgd�ZGd�d��Z					dd
�Z	d�Z
d�Zd
�Zd�Z
d�Zd�Zd�Zd�ZdS)z�
Unified interfaces to root finding algorithms for real or complex
scalar functions.

Functions
---------
- root : find a root of a scalar function.
�N�)�	_zeros_py�root_scalar)�bisect�brentq�brenth�ridder�toms748�newton�secant�halleyc�0�eZdZdZd�Zd�Zd�Zd�Zd�ZdS)�
MemoizeDera�Decorator that caches the value and derivative(s) of function each
    time it is called.

    This is a simplistic memoizer that calls and caches a single value
    of `f(x, *args)`.
    It assumes that `args` does not change between invocations.
    It supports the use case of a root-finder where `args` is fixed,
    `x` changes, and only rarely, if at all, does x assume the same value
    more than once.c�>�||_d|_d|_d|_dS)Nr)�fun�vals�x�n_calls)�selfrs  �=/usr/lib/python3/dist-packages/scipy/optimize/_root_scalar.py�__init__zMemoizeDer.__init__s"�������	���������c��|j�||jkr4|j|g|�R�}||_|xjdz
c_|dd�|_|jdS)z,Calculate f or use cached value if availableNrr)rrrr)rr�args�fgs    r�__call__zMemoizeDer.__call__#sa���9���T�V������!�#�d�#�#�#�B��D�F��L�L�A��L�L��1�1�1��D�I��y��|�rc�R�|j�||jkr	||g|�R�|jdS)z/Calculate f' or use a cached value if availableNr�rr�rrrs   r�fprimezMemoizeDer.fprime-�3���9���T�V����D��N�T�N�N�N�N��y��|�rc�R�|j�||jkr	||g|�R�|jdS)z0Calculate f'' or use a cached value if availableN�rrs   r�fprime2zMemoizeDer.fprime23r!rc��|jS)N)r)rs r�ncallszMemoizeDer.ncalls9s
���|�rN)	�__name__�
__module__�__qualname__�__doc__rrr r$r&�rrrrsi������������������������rrr+c�V�t|t��s|f}|�i}d}|�@t|��s1t|��r t	|��}d}|j}|j}nd}|�9t|��s*t|��rt	|��}d}|j}nd}i}
dD]*}t���|��}|�||
|<�+|r|
�	|��|
�	dd���|s|rd}n|�|r|rd}nd}nd	}|std
���|���}ddd�}	tt|�||����}n%#t$r}td|z��|�d}~wwxYw|d
vrXt|ttt jf��std|z���|dd�\}}||||fd|i|
��\}}�n5|dvrW|�td|z���|�td|z���d|
vr|
�d��|
d<|||f|dd|d�|
��\}}n�|dvrV|�td|z���|std|z���d|
vr|
�d��|
d<|||f||dd�|
��\}}n�|dvrj|�td|z���|std|z���|std|z���d|
vr|
�d��|
d<|||f|||d�|
��\}}ntd|z���|r|j}||_|S)aV
    Find a root of a scalar function.

    Parameters
    ----------
    f : callable
        A function to find a root of.
    args : tuple, optional
        Extra arguments passed to the objective function and its derivative(s).
    method : str, optional
        Type of solver.  Should be one of

            - 'bisect'    :ref:`(see here) <optimize.root_scalar-bisect>`
            - 'brentq'    :ref:`(see here) <optimize.root_scalar-brentq>`
            - 'brenth'    :ref:`(see here) <optimize.root_scalar-brenth>`
            - 'ridder'    :ref:`(see here) <optimize.root_scalar-ridder>`
            - 'toms748'    :ref:`(see here) <optimize.root_scalar-toms748>`
            - 'newton'    :ref:`(see here) <optimize.root_scalar-newton>`
            - 'secant'    :ref:`(see here) <optimize.root_scalar-secant>`
            - 'halley'    :ref:`(see here) <optimize.root_scalar-halley>`

    bracket: A sequence of 2 floats, optional
        An interval bracketing a root.  `f(x, *args)` must have different
        signs at the two endpoints.
    x0 : float, optional
        Initial guess.
    x1 : float, optional
        A second guess.
    fprime : bool or callable, optional
        If `fprime` is a boolean and is True, `f` is assumed to return the
        value of the objective function and of the derivative.
        `fprime` can also be a callable returning the derivative of `f`. In
        this case, it must accept the same arguments as `f`.
    fprime2 : bool or callable, optional
        If `fprime2` is a boolean and is True, `f` is assumed to return the
        value of the objective function and of the
        first and second derivatives.
        `fprime2` can also be a callable returning the second derivative of `f`.
        In this case, it must accept the same arguments as `f`.
    xtol : float, optional
        Tolerance (absolute) for termination.
    rtol : float, optional
        Tolerance (relative) for termination.
    maxiter : int, optional
        Maximum number of iterations.
    options : dict, optional
        A dictionary of solver options. E.g., ``k``, see
        :obj:`show_options()` for details.

    Returns
    -------
    sol : RootResults
        The solution represented as a ``RootResults`` object.
        Important attributes are: ``root`` the solution , ``converged`` a
        boolean flag indicating if the algorithm exited successfully and
        ``flag`` which describes the cause of the termination. See
        `RootResults` for a description of other attributes.

    See also
    --------
    show_options : Additional options accepted by the solvers
    root : Find a root of a vector function.

    Notes
    -----
    This section describes the available solvers that can be selected by the
    'method' parameter.

    The default is to use the best method available for the situation
    presented.
    If a bracket is provided, it may use one of the bracketing methods.
    If a derivative and an initial value are specified, it may
    select one of the derivative-based methods.
    If no method is judged applicable, it will raise an Exception.

    Arguments for each method are as follows (x=required, o=optional).

    +-----------------------------------------------+---+------+---------+----+----+--------+---------+------+------+---------+---------+
    |                    method                     | f | args | bracket | x0 | x1 | fprime | fprime2 | xtol | rtol | maxiter | options |
    +===============================================+===+======+=========+====+====+========+=========+======+======+=========+=========+
    | :ref:`bisect <optimize.root_scalar-bisect>`   | x |  o   |    x    |    |    |        |         |  o   |  o   |    o    |   o     |
    +-----------------------------------------------+---+------+---------+----+----+--------+---------+------+------+---------+---------+
    | :ref:`brentq <optimize.root_scalar-brentq>`   | x |  o   |    x    |    |    |        |         |  o   |  o   |    o    |   o     |
    +-----------------------------------------------+---+------+---------+----+----+--------+---------+------+------+---------+---------+
    | :ref:`brenth <optimize.root_scalar-brenth>`   | x |  o   |    x    |    |    |        |         |  o   |  o   |    o    |   o     |
    +-----------------------------------------------+---+------+---------+----+----+--------+---------+------+------+---------+---------+
    | :ref:`ridder <optimize.root_scalar-ridder>`   | x |  o   |    x    |    |    |        |         |  o   |  o   |    o    |   o     |
    +-----------------------------------------------+---+------+---------+----+----+--------+---------+------+------+---------+---------+
    | :ref:`toms748 <optimize.root_scalar-toms748>` | x |  o   |    x    |    |    |        |         |  o   |  o   |    o    |   o     |
    +-----------------------------------------------+---+------+---------+----+----+--------+---------+------+------+---------+---------+
    | :ref:`newton <optimize.root_scalar-newton>`   | x |  o   |         | x  |    |   x    |         |  o   |  o   |    o    |   o     |
    +-----------------------------------------------+---+------+---------+----+----+--------+---------+------+------+---------+---------+
    | :ref:`secant <optimize.root_scalar-secant>`   | x |  o   |         | x  | x  |        |         |  o   |  o   |    o    |   o     |
    +-----------------------------------------------+---+------+---------+----+----+--------+---------+------+------+---------+---------+
    | :ref:`halley <optimize.root_scalar-halley>`   | x |  o   |         | x  |    |   x    |    x    |  o   |  o   |    o    |   o     |
    +-----------------------------------------------+---+------+---------+----+----+--------+---------+------+------+---------+---------+

    Examples
    --------

    Find the root of a simple cubic

    >>> from scipy import optimize
    >>> def f(x):
    ...     return (x**3 - 1)  # only one real root at x = 1

    >>> def fprime(x):
    ...     return 3*x**2

    The `brentq` method takes as input a bracket

    >>> sol = optimize.root_scalar(f, bracket=[0, 3], method='brentq')
    >>> sol.root, sol.iterations, sol.function_calls
    (1.0, 10, 11)

    The `newton` method takes as input a single point and uses the
    derivative(s).

    >>> sol = optimize.root_scalar(f, x0=0.2, fprime=fprime, method='newton')
    >>> sol.root, sol.iterations, sol.function_calls
    (1.0, 11, 22)

    The function can provide the value and derivative(s) in a single call.

    >>> def f_p_pp(x):
    ...     return (x**3 - 1), 3*x**2, 6*x

    >>> sol = optimize.root_scalar(
    ...     f_p_pp, x0=0.2, fprime=True, method='newton'
    ... )
    >>> sol.root, sol.iterations, sol.function_calls
    (1.0, 11, 11)

    >>> sol = optimize.root_scalar(
    ...     f_p_pp, x0=0.2, fprime=True, fprime2=True, method='halley'
    ... )
    >>> sol.root, sol.iterations, sol.function_calls
    (1.0, 7, 8)


    NFT)�xtol�rtol�maxiter)�full_output�disprr
rrzIUnable to select a solver as neither bracket nor starting point provided.)r
rzUnknown solver %s)rr	rrr
zBracket needed for %sr#r)rzx0 must not be None for %szx1 must not be None for %sr-�tol)rr r$�x1)rzfprime must be specified for %s)rr r$)r
z fprime2 must be specified for %s)�
isinstance�tuple�callable�boolrr$r �locals�get�update�
ValueError�lower�getattr�optzeros�AttributeError�list�np�ndarray�popr�function_calls)�fr�method�bracketr r$�x0r3r-r.r/�options�is_memoized�kwargs�k�v�meth�map2underlying�methodc�e�a�b�r�solrs                         rrr=sj��d�d�E�"�"���w�������K���8�G�#4�#4����=�=�	��1�
�
�A��K��i�G��X�F�F��G�
��(�6�"2�"2����<�<�	��1�
�
�A��K��X�F�F��F��F�
(�����H�H�L�L��O�O���=��F�1�I�����
�
�g�����M�M�d��M�/�/�/��
"��		"��F�F�
�^��
"��&�%�F�F�%�F�F�!���9��8�9�9�	9��<�<�>�>�D� (�H�=�=�N�<��(�N�$6�$6�t�T�$B�$B�C�C�����<�<�<��,�t�3�4�4�!�;�����<�����B�B�B��'�D�%���#<�=�=�	?��4�v�=�>�>�>��r��r�{���1����A�q�6�6�t�6�v�6�6���3�3�	
��	�	�
�:��9�F�B�C�C�C�
�:��9�F�B�C�C�C��V���"�J�J�v�.�.�F�5�M����B�*�T�$���*�*�"(�*�*���3�3�	
��	�	�
�:��9�F�B�C�C�C��	I��>��G�H�H�H��V���"�J�J�v�.�.�F�5�M����B�#�T�&�$�#�#�!�#�#���3�3�	
��	�	�
�:��9�F�B�C�C�C��	I��>��G�H�H�H��	J��?�&�H�I�I�I��V���"�J�J�v�.�.�F�5�M����B�T�T�&�'�T�T�V�T�T���3�3��,�v�5�6�6�6��%��)��$����Js�9)E#�#
F�-F�Fc��dS)a?
    Options
    -------
    args : tuple, optional
        Extra arguments passed to the objective function.
    bracket: A sequence of 2 floats, optional
        An interval bracketing a root.  `f(x, *args)` must have different
        signs at the two endpoints.
    xtol : float, optional
        Tolerance (absolute) for termination.
    rtol : float, optional
        Tolerance (relative) for termination.
    maxiter : int, optional
        Maximum number of iterations.
    options: dict, optional
        Specifies any method-specific options not covered above

    Nr+r+rr�_root_scalar_brentq_docrW<�	��&	�Drc��dS�a@
    Options
    -------
    args : tuple, optional
        Extra arguments passed to the objective function.
    bracket: A sequence of 2 floats, optional
        An interval bracketing a root.  `f(x, *args)` must have different
        signs at the two endpoints.
    xtol : float, optional
        Tolerance (absolute) for termination.
    rtol : float, optional
        Tolerance (relative) for termination.
    maxiter : int, optional
        Maximum number of iterations.
    options: dict, optional
        Specifies any method-specific options not covered above.

    Nr+r+rr�_root_scalar_brenth_docr[RrXrc��dSrZr+r+rr�_root_scalar_toms748_docr]grXrc��dS)a
    Options
    -------
    args : tuple, optional
        Extra arguments passed to the objective function.
    xtol : float, optional
        Tolerance (absolute) for termination.
    rtol : float, optional
        Tolerance (relative) for termination.
    maxiter : int, optional
        Maximum number of iterations.
    x0 : float, required
        Initial guess.
    x1 : float, required
        A second guess.
    options: dict, optional
        Specifies any method-specific options not covered above.

    Nr+r+rr�_root_scalar_secant_docr_}s	��(	�Drc��dS)a"
    Options
    -------
    args : tuple, optional
        Extra arguments passed to the objective function and its derivative.
    xtol : float, optional
        Tolerance (absolute) for termination.
    rtol : float, optional
        Tolerance (relative) for termination.
    maxiter : int, optional
        Maximum number of iterations.
    x0 : float, required
        Initial guess.
    fprime : bool or callable, optional
        If `fprime` is a boolean and is True, `f` is assumed to return the
        value of derivative along with the objective function.
        `fprime` can also be a callable returning the derivative of `f`. In
        this case, it must accept the same arguments as `f`.
    options: dict, optional
        Specifies any method-specific options not covered above.

    Nr+r+rr�_root_scalar_newton_docra�s	��.	�Drc��dS)ar
    Options
    -------
    args : tuple, optional
        Extra arguments passed to the objective function and its derivatives.
    xtol : float, optional
        Tolerance (absolute) for termination.
    rtol : float, optional
        Tolerance (relative) for termination.
    maxiter : int, optional
        Maximum number of iterations.
    x0 : float, required
        Initial guess.
    fprime : bool or callable, required
        If `fprime` is a boolean and is True, `f` is assumed to return the
        value of derivative along with the objective function.
        `fprime` can also be a callable returning the derivative of `f`. In
        this case, it must accept the same arguments as `f`.
    fprime2 : bool or callable, required
        If `fprime2` is a boolean and is True, `f` is assumed to return the
        value of 1st and 2nd derivatives along with the objective function.
        `fprime2` can also be a callable returning the 2nd derivative of `f`.
        In this case, it must accept the same arguments as `f`.
    options: dict, optional
        Specifies any method-specific options not covered above.

    Nr+r+rr�_root_scalar_halley_docrc�s	��8	�Drc��dSrZr+r+rr�_root_scalar_ridder_docre�rXrc��dSrZr+r+rr�_root_scalar_bisect_docrg�rXr)r+NNNNNNNNNN)r*�numpyrA�rr>�__all__�ROOT_SCALAR_METHODSrrrWr[r]r_rarcrergr+rr�<module>rls��������#�#�#�#�#�#��/��5�5�5��'�'�'�'�'�'�'�'�T26�%)� �.2��	|�|�|�|�~	�	�	�,	�	�	�*	�	�	�,	�	�	�.	�	�	�4	�	�	�>	�	�	�,	�	�	�	�	r

Youez - 2016 - github.com/yon3zu
LinuXploit