+
    ‰°³jO  ã                   ó(  € ^RI Ht ^RIHt  ]P
                  t]R 4       tR t	]RR l4       t
R t]RR l4       tR	 t]R
 4       t/ 3R lt]R 4       t]RR l4       t]RR l4       t]R 4       t]R 4       tR#   ] d    ]P                  t Lvi ; i)é   )Úxrange)Údefunc                óê   € \        V4      pV P                  pRV^,          ,          p\        V^,           4       F5  pW4W,          ,          ,          pWEV,
          ,          V^,           ,          pK7  	  V# )z°
Given a sequence `(s_k)` containing at least `n+1` items, returns the
`n`-th forward difference,

.. math ::

    \Delta^n = \sum_{k=0}^{\infty} (-1)^{k+n} {n \choose k} s_k.
éÿÿÿÿ)ÚintÚzeror   )ÚctxÚsÚnÚdÚbÚks   &&&   Ú`/home/luca/screen-checking/.venv/lib/python3.14/site-packages/mpmath/calculus/differentiation.pyÚ
differencer      s]   € ô 	ˆA‹€AØ�‰€AØ	��Q•�€AÜ�A�a•CŽ[ˆØ	�•�X�ˆØ�A•#�Y˜A˜a�CÕ Šñ ð €Hó    c                 ó8  € VP                  R 4      pVP                  R^
4      pVP                  R^ 4      pV^V,          ,           V^,           ,          p	V P                  p
 W�n        VP                  R4      pVfW   VP                  R4      '       d   \        V P                  V4      4      pM^ pV P	                  ^V) V,
          V,
          4      pMV P                  V4      pVP                  R^ 4      pV'       d-   W°P                  V4      ,          p\        V^,           4      pTpM\        V) V^,           ^4      p^V,          pV'       d   VRV,          ,          pV Uu. uF  qñ! W/V,          ,           4      NK  	  ppVWé3W n        # u upi   Y n        i ; i)ÚsingularÚaddprecÚ	directionÚhÚrelativeg      à?)ÚgetÚprecr   ÚmagÚldexpÚconvertÚsignr   )r	   ÚfÚxr   r   Úoptionsr   r   r   ÚworkprecÚorigr   Ú	hextramagÚstepsÚnormr   Úvaluess   &&&&&,           r   Úhstepsr'      sW  € Ø�{‰{˜:Ó&€HØ�k‰k˜) RÓ(€GØ—‘˜K¨Ó+€IØ�Q�w•Y• 1 Q¥3Õ'€HØ�8‰8€DðØŒØ�K‰K˜ÓˆØŠ9Ø�{‰{˜:×&Ò&Ü §¡¨£
›O‘	à�	Ø—	‘	˜!˜d˜U 7�]¨9Õ4Ó5‰Aà—‘˜A“ˆAà—K‘K ¨QÓ/ˆ	ßØ—‘˜)Ó$Õ$ˆAÜ˜1˜Q�3“KˆEØ‰Dô ˜A˜2˜q �s AÓ&ˆEØ�a•CˆDçØ��Q•�JˆAÙ$)Ó*¡E˜q�!�A˜•c•E–(¡EˆÐ*Ø�tÐ%à�ùò +øð �ús2   Á!1F ÂA)F Ã=AF ÅF Å#FÆ F ÆF ÆFc                ó¬  a aaaa€ Rp \        S4      p\        S4      oRpV'       d1   S Uu. uF  pS P                  V4      NK  	  upo\        S SSXV4      # VP	                  RR4      pS^ 8X  d6   VR8w  d/   VP	                  R4      '       g   S! S P                  S4      4      # S P
                  p	 VR8X  d<   \        S SSSV	3/ VB w  r«pVS n        S P                  V
S4      VS,          ,          pM³VR8X  d›   S ;P
                  ^
,          un        S P                  VP	                  RR4      4      oV VVVV3R	 lpS P                  V^ ^S P                  ,          .4      pVS P                  S4      ,          ^S P                  ,          ,          pM\        R
V,          4      hV	S n        V5#   \         d     EL i ; iu upi   T	S n        i ; i)a|  
Numerically computes the derivative of `f`, `f'(x)`, or generally for
an integer `n \ge 0`, the `n`-th derivative `f^{(n)}(x)`.
A few basic examples are::

    >>> from mpmath import *
    >>> mp.dps = 15; mp.pretty = True
    >>> diff(lambda x: x**2 + x, 1.0)
    3.0
    >>> diff(lambda x: x**2 + x, 1.0, 2)
    2.0
    >>> diff(lambda x: x**2 + x, 1.0, 3)
    0.0
    >>> nprint([diff(exp, 3, n) for n in range(5)])   # exp'(x) = exp(x)
    [20.0855, 20.0855, 20.0855, 20.0855, 20.0855]

Even more generally, given a tuple of arguments `(x_1, \ldots, x_k)`
and order `(n_1, \ldots, n_k)`, the partial derivative
`f^{(n_1,\ldots,n_k)}(x_1,\ldots,x_k)` is evaluated. For example::

    >>> diff(lambda x,y: 3*x*y + 2*y - x, (0.25, 0.5), (0,1))
    2.75
    >>> diff(lambda x,y: 3*x*y + 2*y - x, (0.25, 0.5), (1,1))
    3.0

**Options**

The following optional keyword arguments are recognized:

``method``
    Supported methods are ``'step'`` or ``'quad'``: derivatives may be
    computed using either a finite difference with a small step
    size `h` (default), or numerical quadrature.
``direction``
    Direction of finite difference: can be -1 for a left
    difference, 0 for a central difference (default), or +1
    for a right difference; more generally can be any complex number.
``addprec``
    Extra precision for `h` used to account for the function's
    sensitivity to perturbations (default = 10).
``relative``
    Choose `h` relative to the magnitude of `x`, rather than an
    absolute value; useful for large or tiny `x` (default = False).
``h``
    As an alternative to ``addprec`` and ``relative``, manually
    select the step size `h`.
``singular``
    If True, evaluation exactly at the point `x` is avoided; this is
    useful for differentiating functions with removable singularities.
    Default = False.
``radius``
    Radius of integration contour (with ``method = 'quad'``).
    Default = 0.25. A larger radius typically is faster and more
    accurate, but it must be chosen so that `f` has no
    singularities within the radius from the evaluation point.

A finite difference requires `n+1` function evaluations and must be
performed at `(n+1)` times the target precision. Accordingly, `f` must
support fast evaluation at high precision.

With integration, a larger number of function evaluations is
required, but not much extra precision is required. For high order
derivatives, this method may thus be faster if f is very expensive to
evaluate at high precision.

**Further examples**

The direction option is useful for computing left- or right-sided
derivatives of nonsmooth functions::

    >>> diff(abs, 0, direction=0)
    0.0
    >>> diff(abs, 0, direction=1)
    1.0
    >>> diff(abs, 0, direction=-1)
    -1.0

More generally, if the direction is nonzero, a right difference
is computed where the step size is multiplied by sign(direction).
For example, with direction=+j, the derivative from the positive
imaginary direction will be computed::

    >>> diff(abs, 0, direction=j)
    (0.0 - 1.0j)

With integration, the result may have a small imaginary part
even even if the result is purely real::

    >>> diff(sqrt, 1, method='quad')    # doctest:+ELLIPSIS
    (0.5 - 4.59...e-26j)
    >>> chop(_)
    0.5

Adding precision to obtain an accurate value::

    >>> diff(cos, 1e-30)
    0.0
    >>> diff(cos, 1e-30, h=0.0001)
    -9.99999998328279e-31
    >>> diff(cos, 1e-30, addprec=100)
    -1.0e-30

FTÚmethodÚstepÚquadr   Úradiusg      Ð?c                 ór   <€ SSP                  V 4      ,          pSV,           pS! V4      VS,          ,          # ©N)Úexpj)ÚtÚreiÚzr	   r   r   r,   r   s   &  €€€€€r   ÚgÚdiff.<locals>.gÂ   s0   ø€ Ø˜SŸX™X a›[Õ(�Ø˜•G�Ù˜“t˜c 1�f•}Ð$r   zunknown method: %r)ÚlistÚ	TypeErrorr   Ú_partial_diffr   r   r'   r   ÚquadtsÚpiÚ	factorialÚ
ValueError)r	   r   r   r   r    ÚpartialÚordersÚ_r)   r   r&   r%   r!   Úvr3   r   r,   s   ffff,           @r   Údiffr@   C   s¤  ü€ ðR €GðÜ�a“ˆÜ�‹GˆØˆ÷ Ù%&Ó'¡Q ˆS�[‰[˜Ž^¡QÑ'ˆÜ˜S ! Q¨°Ó8Ð8Ø�[‰[˜ 6Ó*€FØˆA„v�&˜FÔ"¨7¯;©;°z×+BÒ+BÙ�—‘˜Q“Ó Ð Ø�8‰8€DðØ�VÔÜ%+¨C°°A°q¸$Ñ%JÀ'Ñ%JÑ"ˆF˜(ØˆCŒHØ—‘˜v qÓ)¨D°!­GÕ3‰AØ�vÔØ�HŠH˜�N�HØ—[‘[ §¡¨X°tÓ!<Ó=ˆF÷%ñ %ð —
‘
˜1˜q ! C§F¡F¥(˜mÓ,ˆAØ�C—M‘M !Ó$Õ$¨¨#¯&©&­Õ1‰AäÐ1°FÕ:Ó;Ð;àˆŒØˆ2€Iøô7 ô Úðüò (øð. ˆ�ús#   ‰F3 ­GÂ4C5G
 Æ3GÇGÇ
	Gc                 ó   a aaaa€ V'       g   S! 4       # \        V4      '       g   S! V!  # ^ o\        \        V4      4       F  oVS,          '       g   K   M	  VS,          oV VVVV3R lp^ VS&   \        S WRVS4      # )é    c                  óN   <a € VV V3R  lpSP                   ! VS S,          S3/ SB # )c                 óH   <€ S! SR S V 3,           SS^,           R  ,           !  # r.   © )r0   r   Úf_argsÚis   &€€€r   ÚinnerÚ1_partial_diff.<locals>.fdiff_inner.<locals>.innerÙ   s*   ø€ Ù�v˜b˜q�z Q DÕ(¨6°!°Aµ#°$¨<Õ7Ñ9Ð9r   ©r@   )rF   rH   r	   r   rG   r    Úorders   j €€€€€r   Úfdiff_innerÚ"_partial_diff.<locals>.fdiff_innerØ   s$   ù€ ÷	:à�xŠx˜˜v a�y¨%Ñ;°7Ñ;Ð;r   )ÚsumÚrangeÚlenr7   )r	   r   Úxsr=   r    rL   rG   rK   s   ff&&f @@r   r7   r7   Î   st   ü€ ßÙ‹sˆ
Üˆv�;Š;Ù�"‰vˆØ	€AÜ”3�v“;ÖˆØ�!�9Ž9Ùñ  ð �1�I€E÷<ñ <ð €Fˆ1�IÜ˜˜k¨v°wÓ?Ð?r   Nc              +  óê  "  € Vf   V P                   pM\        V4      pVP                  RR4      R8w  d3   ^ pWS^,           8  d"   V P                  ! WV3/ VB x € V^,          pK.  R# VP                  R4      pV'       d   V P                  W^ RR7      x € MV! V P	                  V4      4      x € V^8  d   R# W0P                   8X  d   ^^r‡M
^V^,           r‡ V P
                  p	\        WW(V	3/ VB w  r«p\        Wx4       F<  p WÀn        V P                  W¥4      Wµ,          ,          pW�n        V5x € WS8¼  g   K;   R# 	  T\        VR,          ^,           4      r‡\        Wƒ4      pK�    Y�n        i ; i5i)aø  
Returns a generator that yields the sequence of derivatives

.. math ::

    f(x), f'(x), f''(x), \ldots, f^{(k)}(x), \ldots

With ``method='step'``, :func:`~mpmath.diffs` uses only `O(k)`
function evaluations to generate the first `k` derivatives,
rather than the roughly `O(k^2)` evaluations
required if one calls :func:`~mpmath.diff` `k` separate times.

With `n < \infty`, the generator stops as soon as the
`n`-th derivative has been generated. If the exact number of
needed derivatives is known in advance, this is further
slightly more efficient.

Options are the same as for :func:`~mpmath.diff`.

**Examples**

    >>> from mpmath import *
    >>> mp.dps = 15
    >>> nprint(list(diffs(cos, 1, 5)))
    [0.540302, -0.841471, -0.540302, 0.841471, 0.540302, -0.841471]
    >>> for i, d in zip(range(6), diffs(cos, 1)):
    ...     print("%s %s" % (i, d))
    ...
    0 0.54030230586814
    1 -0.841470984807897
    2 -0.54030230586814
    3 0.841470984807897
    4 0.54030230586814
    5 -0.841470984807897

Nr)   r*   r   T)r   gffffffö?)
Úinfr   r   r@   r   r   r'   r   r   Úmin)r	   r   r   r   r    r   r   ÚAÚBÚcallprecÚyr%   r!   r   s   &&&&,         r   ÚdiffsrY   ß   sK  é € ðL 	‚yØ�G‰G‰ä�‹FˆØ‡{�{�8˜VÓ$¨Ô.ØˆØ�a•%ŒiØ—(’(˜1 Ñ. gÑ.Ò.Ø��FŠAÙØ�{‰{˜:Ó&€HßØ�h‰h�q˜Q¨ˆhÓ.Ó.á�—‘˜A“ÓÒØˆ1„uÙØ�G‰G„|Ø�!‰1à�!�A•#ˆ1Ø
Ø—8‘8ˆÜ" 3¨1°ÑE¸WÑEÑˆ�Ü˜–ˆAð$Ø#”Ø—N‘N 1Ó(¨4­7Õ2�à#”Ø�"ŠHØŽvÚñ ð ”#�a˜•e˜A•g“,ˆ1Ü�‹IŠøð $•üs+   ‚A>E3ÂBE3Ä$E(Ä)E3Ä<,E3Å(E0Å0E3c                 ó2   a a€ \        S 4      o . oVV 3R  lpV# )c                 ó�   <€ \        \        S4      V ^,           4       F  pSP                  \        S4      4       K  	  SV ,          # ©é   )r   rP   ÚappendÚnext)r   rG   ÚdataÚgens   & €€r   r   Úiterable_to_function.<locals>.f,  s5   ø€ Üœ˜D›	 1 Q¥3Ö'ˆAØ�K‰Kœ˜S›	Ö"ñ (à�A�wˆr   )Úiter)ra   r   r`   s   f @r   Úiterable_to_functionrd   )  s   ù€ Ü
ˆs‹)€CØ€Döð €Hr   c              #  óø  "  € \        V4      pV^8X  d   V^ ,           F  pVx € K	  	  R# \        V P                  VRV^,           4      4      p\        V P                  W^,          R 4      4      p^ p V! V4      V! ^ 4      ,          p^p\        ^V^,           4       FH  p	W†V	,
          ^,           ,          V	,          pWxV! Wi,
          4      ,          V! V	4      ,          ,          pKJ  	  Vx € V^,          pK†  5i)aæ  
Given a list of `N` iterables or generators yielding
`f_k(x), f'_k(x), f''_k(x), \ldots` for `k = 1, \ldots, N`,
generate `g(x), g'(x), g''(x), \ldots` where
`g(x) = f_1(x) f_2(x) \cdots f_N(x)`.

At high precision and for large orders, this is typically more efficient
than numerical differentiation if the derivatives of each `f_k(x)`
admit direct computation.

Note: This function does not increase the working precision internally,
so guard digits may have to be added externally for full accuracy.

**Examples**

    >>> from mpmath import *
    >>> mp.dps = 15; mp.pretty = True
    >>> f = lambda x: exp(x)*cos(x)*sin(x)
    >>> u = diffs(f, 1)
    >>> v = mp.diffs_prod([diffs(exp,1), diffs(cos,1), diffs(sin,1)])
    >>> next(u); next(v)
    1.23586333600241
    1.23586333600241
    >>> next(u); next(v)
    0.104658952245596
    0.104658952245596
    >>> next(u); next(v)
    -5.96999877552086
    -5.96999877552086
    >>> next(u); next(v)
    -12.4632923122697
    -12.4632923122697

N)rP   rd   Ú
diffs_prodr   )
r	   ÚfactorsÚNÚcÚur?   r   r
   Úar   s
   &&        r   rf   rf   2  sØ   é € ôH 	ˆG‹€AØˆA„vØ˜—�ˆAØŒGó ô ! §¡°¸¸¸A½°Ó!?Ó@ˆÜ  §¡°¸1½¸°Ó!?Ó@ˆØˆØá�!“‘q˜“t•ˆAØˆAÜ˜A˜a �c–]�Ø˜1�˜Q�•K 1Õ$�Ø™˜1�3›•Z¡! A£$Õ&Õ&’ñ #ð ŠGØ��FŠAùs   ‚C8C:c                ó¬  € W9   d	   W,          # V'       g   R^/V^ &   \        V ^,
          4      p\        R \        V4       4       4      p/ p\        V4       FD  w  rEV^ ,          ^,           3VR,          ,           pWc9   d   W6;;,          V,          uu&   K@  WSV&   KF  	  \        V4       F›  w  rE\        V4      '       g   K  \	        V4       Ft  w  rxV'       g   K  VRV V^,
          WG^,           ,          ^,           3,           WG^,           R ,           p	W“9   d   W9;;,          W…,          ,          uu&   Kj  W…,          W9&   Kv  	  K�  	  W1V &   W,          # )z”
nth differentiation polynomial for exp (Faa di Bruno's formula).

TODO: most exponents are zero, so maybe a sparse representation
would be better.
c              3   ó<   "  € T F  w  rVR,           V3x € K  	  R# 5i)rB   N©rB   rE   )Ú.0ri   r?   s   &  r   Ú	<genexpr>Údpoly.<locals>.<genexpr>t  s   é € Ð2¡\™E˜Qˆa��f�Q�Z£\ùs   ‚:r]   NNNrn   )ÚdpolyÚdictÚ	iteritemsrN   Ú	enumerate)
r   Ú_cacheÚRÚRaÚpowersÚcountÚpowers1r   ÚpÚpowers2s
   &&        r   rr   rr   h  s  € ð 	„{Ø�yÐßØ˜!�Hˆˆq‰	Üˆa��c‹
€AÜÑ2¤Y¨q¤\Ó2Ó2€AØ	€BÜ" 1ž‰ˆØ˜!•9˜Q•;�. 6¨"¥:Õ-ˆØŒ=Ø�K˜5Õ �Kàˆw‹Kñ &ô # 1ž‰ˆÜ�6�{Š{ÙÜ˜VÖ$‰CˆAß‰qØ   !˜*¨¨!­¨F°Qµ3­K¸­MÐ':Õ:¸VÀaÅCÀD¸\ÕI�Ø”=Ø—K 1¥7Õ*•Kà"#¥'�B“Kó %ñ &ð ˆ1�IØ�9Ðr   c           	   #  óF  a"  € \        V4      oV P                  S! ^ 4      4      pVx € ^p V P                  ^ 4      p\        \	        V4      4       F6  w  rVWFV P                  V3R l\        V4       4       4      ,          ,          pK8  	  WB,          x € V^,          pKu  5i)aD  
Given an iterable or generator yielding `f(x), f'(x), f''(x), \ldots`
generate `g(x), g'(x), g''(x), \ldots` where `g(x) = \exp(f(x))`.

At high precision and for large orders, this is typically more efficient
than numerical differentiation if the derivatives of `f(x)`
admit direct computation.

Note: This function does not increase the working precision internally,
so guard digits may have to be added externally for full accuracy.

**Examples**

The derivatives of the gamma function can be computed using
logarithmic differentiation::

    >>> from mpmath import *
    >>> mp.dps = 15; mp.pretty = True
    >>>
    >>> def diffs_loggamma(x):
    ...     yield loggamma(x)
    ...     i = 0
    ...     while 1:
    ...         yield psi(i,x)
    ...         i += 1
    ...
    >>> u = diffs_exp(diffs_loggamma(3))
    >>> v = diffs(gamma, 3)
    >>> next(u); next(v)
    2.0
    2.0
    >>> next(u); next(v)
    1.84556867019693
    1.84556867019693
    >>> next(u); next(v)
    2.49292999190269
    2.49292999190269
    >>> next(u); next(v)
    3.44996501352367
    3.44996501352367

c              3   óh   <"  € T F'  w  rV'       g   K  S! V^,           4      V,          x € K)  	  R# 5i)r]   NrE   )ro   r   r|   Úfns   &  €r   rp   Údiffs_exp.<locals>.<genexpr>¼  s'   øé € ÐLÑ5F©E¨QÌ!œZ™R  !¥›W aŸZšZÓ5Fùs   ƒ2”2)rd   ÚexpÚmpfrt   rr   Úfprodru   )r	   ÚfdiffsÚf0rG   r
   ry   ri   r€   s   &&     @r   Ú	diffs_expr‡   ‰  s„   øé € ôX 
˜fÓ	%€BØ	�‰‘�A“‹€BØ
‚HØ	€AØ
Ø�G‰G�A‹JˆÜ"¤5¨£8Ö,‰IˆFØ�3—9‘9ÔL´Y¸vÔ5FÓLÓLÕLÕLŠAñ -à�fŠØ	ˆQ�Šùs   ƒBB!c           	     ó
  a aaa€ \        \        S P                  S P                  V4      4      4      ^,           ^4      pWS,
          ^,
          oV VVV3R lpS P	                  WbV4      S P                  WS,
          4      ,          # )a¹  
Calculates the Riemann-Liouville differintegral, or fractional
derivative, defined by

.. math ::

    \,_{x_0}{\mathbb{D}}^n_xf(x) = \frac{1}{\Gamma(m-n)} \frac{d^m}{dx^m}
    \int_{x_0}^{x}(x-t)^{m-n-1}f(t)dt

where `f` is a given (presumably well-behaved) function,
`x` is the evaluation point, `n` is the order, and `x_0` is
the reference point of integration (`m` is an arbitrary
parameter selected automatically).

With `n = 1`, this is just the standard derivative `f'(x)`; with `n = 2`,
the second derivative `f''(x)`, etc. With `n = -1`, it gives
`\int_{x_0}^x f(t) dt`, with `n = -2`
it gives `\int_{x_0}^x \left( \int_{x_0}^t f(u) du \right) dt`, etc.

As `n` is permitted to be any number, this operator generalizes
iterated differentiation and iterated integration to a single
operator with a continuous order parameter.

**Examples**

There is an exact formula for the fractional derivative of a
monomial `x^p`, which may be used as a reference. For example,
the following gives a half-derivative (order 0.5)::

    >>> from mpmath import *
    >>> mp.dps = 15; mp.pretty = True
    >>> x = mpf(3); p = 2; n = 0.5
    >>> differint(lambda t: t**p, x, n)
    7.81764019044672
    >>> gamma(p+1)/gamma(p-n+1) * x**(p-n)
    7.81764019044672

Another useful test function is the exponential function, whose
integration / differentiation formula easy generalizes
to arbitrary order. Here we first compute a third derivative,
and then a triply nested integral. (The reference point `x_0`
is set to `-\infty` to avoid nonzero endpoint terms.)::

    >>> differint(lambda x: exp(pi*x), -1.5, 3)
    0.278538406900792
    >>> exp(pi*-1.5) * pi**3
    0.278538406900792
    >>> differint(lambda x: exp(pi*x), 3.5, -3, -inf)
    1922.50563031149
    >>> exp(pi*3.5) / pi**3
    1922.50563031149

However, for noninteger `n`, the differentiation formula for the
exponential function must be modified to give the same result as the
Riemann-Liouville differintegral::

    >>> x = mpf(3.5)
    >>> c = pi
    >>> n = 1+2*j
    >>> differint(lambda x: exp(c*x), x, n)
    (-123295.005390743 + 140955.117867654j)
    >>> x**(-n) * exp(c)**x * (x*c)**n * gammainc(-n, 0, x*c) / gamma(-n)
    (-123295.005390743 + 140955.117867654j)


c                 ó:   <a € SP                  VVV 3R  lSS .4      # )c                 ó>   <€ SV ,
          S,          S! V 4      ,          # r.   rE   )r0   r   Úrr   s   &€€€r   Ú<lambda>Ú-differint.<locals>.<lambda>.<locals>.<lambda>  s   ø€  a¨¥c¨A¥X±°!³¦_r   )r+   )r   r	   r   r‹   Úx0s   f€€€€r   rŒ   Údifferint.<locals>.<lambda>  s   ù€ �#—(‘(Ö4°r¸1°gÔ>r   )Úmaxr   ÚceilÚrer@   Úgamma)r	   r   r   r   rŽ   Úmr3   r‹   s   ff&&f  @r   Ú	differintr•   À  s]   û€ ôH 	ŒC�—‘˜Ÿ™ ›Ó#Ó$ QÕ&¨Ó*€AØ	�ˆA�€Aß>€AØ�8‰8�A˜!Ó˜sŸy™y¨­›~Õ-Ð-r   c                ó2   a aaa€ S^ 8X  d   S# V VVV3R lpV# )aû  
Given a function `f`, returns a function `g(x)` that evaluates the nth
derivative `f^{(n)}(x)`::

    >>> from mpmath import *
    >>> mp.dps = 15; mp.pretty = True
    >>> cos2 = diffun(sin)
    >>> sin2 = diffun(sin, 4)
    >>> cos(1.3), cos2(1.3)
    (0.267498828624587, 0.267498828624587)
    >>> sin(1.3), sin2(1.3)
    (0.963558185417193, 0.963558185417193)

The function `f` must support arbitrary precision evaluation.
See :func:`~mpmath.diff` for additional details and supported
keyword options.
c                 ó.   <€ SP                   ! SV S3/ SB # r.   rJ   )r   r	   r   r   r    s   &€€€€r   r3   Údiffun.<locals>.g  s   ø€ Ø�xŠx˜˜1˜aÑ+ 7Ñ+Ð+r   rE   )r	   r   r   r    r3   s   fffl r   Údiffunr™   	  s    û€ ð& 	ˆA„vØˆ÷,ð ,à€Hr   c                óP  € \        V P                  ! WV3/ VB 4      pVP                  RR4      '       d<   V UUu. uF,  w  rgV P                  V4      V P	                  V4      ,          NK.  	  upp# V UUu. uF  w  rgWpP	                  V4      ,          NK  	  upp# u uppi u uppi )aW  
Produces a degree-`n` Taylor polynomial around the point `x` of the
given function `f`. The coefficients are returned as a list.

    >>> from mpmath import *
    >>> mp.dps = 15; mp.pretty = True
    >>> nprint(chop(taylor(sin, 0, 5)))
    [0.0, 1.0, 0.0, -0.166667, 0.0, 0.00833333]

The coefficients are computed using high-order numerical
differentiation. The function must be possible to evaluate
to arbitrary precision. See :func:`~mpmath.diff` for additional details
and supported keyword options.

Note that to evaluate the Taylor polynomial as an approximation
of `f`, e.g. with :func:`~mpmath.polyval`, the coefficients must be reversed,
and the point of the Taylor expansion must be subtracted from
the argument:

    >>> p = taylor(exp, 2.0, 10)
    >>> polyval(p[::-1], 2.5 - 2.0)
    12.1824939606092
    >>> exp(2.5)
    12.1824939607035

ÚchopT)ru   rY   r   r›   r:   )r	   r   r   r   r    ra   rG   r   s   &&&&,   r   Útaylorrœ   "  s�   € ô8 �C—I’I˜a AÑ1¨Ñ1Ó
2€CØ‡{�{�6˜4× Ò Ù9<Ô=¹±°�—‘˜“˜CŸM™M¨!Ó,×,Ð,¹Ò=Ð=á/2Ô3©s¡t q�—-‘- Ó"×"Ð"©sÒ3Ð3ùó >ùã3s   »2BÁ6"B"c                óJ  € \        V4      W#,           ^,           8  d   \        R4      hV^ 8X  d;   V^ 8X  d   V P                  .V P                  .3# VRV^,            V P                  .3# V P                  V4      p\	        V4       FF  p\	        \        W2V,           ^,           4      4       F  pWV,           V,
          ,          WEV3&   K  	  KH  	  V P                  W^,           W#,           ^,            4      ) pV P                  WG4      pV P                  .\        V4      ,           p	^ .V^,           ,          p
\	        V^,           4       FU  pW,          p\	        ^\        W64      ^,           4       F&  pW¹V,          WV,
          ,          ,          ,          pK(  	  WºV&   KW  	  W©3# )ax  
Computes a Pade approximation of degree `(L, M)` to a function.
Given at least `L+M+1` Taylor coefficients `a` approximating
a function `A(x)`, :func:`~mpmath.pade` returns coefficients of
polynomials `P, Q` satisfying

.. math ::

    P = \sum_{k=0}^L p_k x^k

    Q = \sum_{k=0}^M q_k x^k

    Q_0 = 1

    A(x) Q(x) = P(x) + O(x^{L+M+1})

`P(x)/Q(x)` can provide a good approximation to an analytic function
beyond the radius of convergence of its Taylor series (example
from G.A. Baker 'Essentials of Pade Approximants' Academic Press,
Ch.1A)::

    >>> from mpmath import *
    >>> mp.dps = 15; mp.pretty = True
    >>> one = mpf(1)
    >>> def f(x):
    ...     return sqrt((one + 2*x)/(one + x))
    ...
    >>> a = taylor(f, 0, 6)
    >>> p, q = pade(a, 3, 3)
    >>> x = 10
    >>> polyval(p[::-1], x)/polyval(q[::-1], x)
    1.38169105566806
    >>> f(x)
    1.38169855941551

z%L+M+1 Coefficients should be providedN)rP   r;   ÚoneÚmatrixrO   rT   Úlu_solver5   )r	   rk   ÚLÚMrU   ÚjrG   r?   r   Úqr|   r
   s   &&&&        r   Úpader¥   D  sZ  € ôP ˆ1ƒv�•�A•„~ÜÐ@ÓAÐAàˆA„vØ�Œ6Ø—G‘G�9˜sŸw™w˜iÐ'Ð'à�T�a˜•c�7˜SŸW™W˜IÐ%Ð%ð 	�
‰
�1‹€AÜ�1ŽXˆÜ”s˜1 �c !�e“}Ö%ˆAØ˜!�˜A�•hˆA�ˆd‹Gó &ñ ð 
�‰�A˜•s˜Q�S �UÐ$Ó	%Ð%€AØ�‰�QÓ€AØ	�‰ˆ	”D˜“GÕ€Aà	
ˆˆQˆq�S�	€AÜ�1�Q•3ŽZˆØ�DˆÜ�qœ#˜a›( Q�,Ö'ˆAØ�1•�a˜!�•f•ÕŠAñ (àˆ!‹ñ	 ð
 ˆ4€Kr   r\   r.   )r]   rB   )Úlibmp.backendr   Úcalculusr   rs   rt   ÚAttributeErrorÚitemsr   r'   r@   r7   rY   rd   rf   rr   r‡   r•   r™   rœ   r¥   rE   r   r   Ú<module>rª      s  ðÝ "Ý ðØ—‘€Ið ñó ðò"!ðH óHó ðHòT@ð" óGó ðGòRð ñ3ó ð3ðj ô ðB ñ4ó ð4ðl óF.ó ðF.ðP óó ðð0 ñ4ó ð4ðB ñBó òBøð ô Ø—
‘
‚Iðús   ŽA; Á;BÂB