ó
    ˆ*£hƒ)  ã                   ó   • S r SSKJrJr  SSKJr  SSKJr   " S S\5      r	SS	/S
SS
S
/ S
4S jr
S r/ SQrS rSS	/SS	/SS
SS
S
S
4S jrSS	/SS	/SSSS
S
S
4S jr\
\	l
        \\	l        \\	l        \\	l        \\	l        g
)z 
Plotting (requires matplotlib)
é    )Ú
hsv_to_rgbÚ
hls_to_rgbé   )ÚNoConvergence)Úxrangec                   ó    • \ rS rSr\\\\4rSr	g)ÚVisualizationMethodsé	   © N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú
ValueErrorÚArithmeticErrorÚZeroDivisionErrorr   Úplot_ignoreÚ__static_attributes__r   ó    ÚQ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/mpmath/visualization.pyr	   r	   	   s   † Ø˜Ð0AÀ=ÐQƒKr   r	   éûÿÿÿé   NéÈ   c	           	      ó   • U(       a  SnSn	U(       d%  SSK n
U
R                  5       n	U	R                  S5      n[        U[        [
        45      (       d  U/nUu  p¼/ SQn[        U5       GHW  u  pïU R                  X¼XË-
  [        U5      -  5      n/ n/ nSn[        [        U5      5       GHI  n US:w  a&  U H   nUUS-
     U::  d  M  UU   U:¼  d  M  [        e   U" UU   5      nU R                  U5      (       d  [        U5      S:”  a  [        e[        US5      (       ay  UR                  (       ah  [        UR                   5      n[        UR                  5      nU(       d  S	nUR#                  U5        / nUR#                  [        UU   5      UU45        Mñ  U(       a  SnUR#                  U5        / n[        US
5      (       a  UR                   nUR#                  [        UU   5      U45        GML     U(       a  UR#                  U5        U H«  nU Vs/ s H  nUS   PM
     nnU Vs/ s H  nUS   PM
     nnU(       d  M6  XÞ[        U5      -     n[        US   5      S:X  aA  U Vs/ s H  nUS   PM
     nnUR'                  UUSU-   SS9  UR'                  UUSU-   SS9  M™  UR'                  UUUSS9  M­     GMZ     UR)                  U Vs/ s H  n[        U5      PM     sn5        U(       a+  UR+                  U Vs/ s H  n[        U5      PM     sn5        UR-                  S5        UR/                  S5        UR1                  S	5        U	(       a(  U(       a  W
R3                  XVS9  gW
R5                  5         gg! U R$                   a    U(       a  UR#                  U5        / n GM
  f = fs  snf s  snf s  snf s  snf s  snf )aˆ  
Shows a simple 2D plot of a function `f(x)` or list of functions
`[f_0(x), f_1(x), \ldots, f_n(x)]` over a given interval
specified by *xlim*. Some examples::

    plot(lambda x: exp(x)*li(x), [1, 4])
    plot([cos, sin], [-4, 4])
    plot([fresnels, fresnelc], [-4, 4])
    plot([sqrt, cbrt], [-4, 4])
    plot(lambda t: zeta(0.5+t*j), [-20, 20])
    plot([floor, ceil, abs, sign], [-5, 5])

Points where the function raises a numerical exception or
returns an infinite value are removed from the graph.
Singularities can also be excluded explicitly
as follows (useful for removing erroneous vertical lines)::

    plot(cot, ylim=[-5, 5])   # bad
    plot(cot, ylim=[-5, 5], singularities=[-pi, 0, pi])  # good

For parts where the function assumes complex values, the
real part is plotted with dashes and the imaginary part
is plotted with dots.

.. note :: This function requires matplotlib (pylab).
Nr   éo   )ÚbÚrÚgÚmÚkFr   gœu ˆ<ä7~ÚimagTÚrealé   é   z--)Ú	linewidthÚ:Úxzf(x)©Údpi)ÚpylabÚfigureÚadd_subplotÚ
isinstanceÚtupleÚlistÚ	enumerateÚarangeÚfloatr   Úlenr   ÚisnanÚabsÚhasattrr!   r"   Úappendr   ÚplotÚset_xlimÚset_ylimÚ
set_xlabelÚ
set_ylabelÚgridÚsavefigÚshow)ÚctxÚfÚxlimÚylimÚpointsÚfiler)   ÚsingularitiesÚaxesÚfigr*   Úar   ÚcolorsÚnÚfuncr'   ÚsegmentsÚsegmentÚ
in_complexÚiÚsingÚvÚreÚimÚsÚyÚcÚzÚ_s                                 r   r8   r8      s>  € ö8 ØˆØ
€CÞÛØ�l‰l‹nˆØ�‰˜sÓ#ˆÜ�aœ%¤˜×'Ñ'ØˆCˆØ�D€AÚ&€FÜ˜Q—<‰ˆØ�J‰J�q˜a™c¤5¨£=Ñ0Ó1ˆØˆØˆØˆ
Üœ˜A›—ˆAðØ˜“6Û -˜Ø˜Q˜q™S™6 T�>¨a°©d°d­lÜ",Ð,ñ !.ñ ˜˜1™“J�Ø—9‘9˜Q—<‘<¤3 q£6¨E£>Ü$Ð$Ü˜1˜f×%Ñ%¨!¯&¯&Ü˜qŸv™v›�BÜ˜qŸv™v›�BÞ%Ø%)˜
Ø Ÿ™¨Ô0Ø"$˜Ø—N‘N¤E¨!¨A©$£K°°RÐ#8Ö9æ!Ø%*˜
Ø Ÿ™¨Ô0Ø"$˜Ü˜q &×)Ñ)ØŸF™F˜Ø—N‘N¤E¨!¨A©$£K°Ð#3×4ñ1  ö: Ø�O‰O˜GÔ$ÛˆGÙ&Ó'šw˜!��1”™wˆAÐ'Ù&Ó'šw˜!��1”™wˆAÐ'ÞÙØœ3˜v›;‘Ñ'ˆAÜ�7˜1‘:‹ !Ó#Ù#*Ó+¢7˜a�Q�q”T¡7�Ð+Ø—	‘	˜!˜Q  Q¡°!�	Ñ4Ø—	‘	˜!˜Q  A¡°�	Ó3à—	‘	˜!˜Q ¨Q�	Ó/ô  ñI  ð` 	‡M�M¡TÓ*¢T ”5˜–8¡TÑ*Ô+ÞØ�‰©Ó.ª A”u˜Q–x©Ñ.Ô/Ø‡O�O�CÔØ‡O�O�FÔØ‡I�Iˆd„OÞ
ÞØ�M‰M˜$ˆMÒ(à�J‰J�Lð	 øð1 —?‘?ó ÞØ—O‘O GÔ,Ø”ðüò (ùÚ'ùò
 ,ùò
 +ùâ.sD   Â.NÃNÃCNÆANÈN7È-N<É-OËOÌOÎ*N4Î3N4c                 ó8  • U R                  U5      (       a  gU R                  U5      (       a  gSn[        U R                  U5      5      U R                  -   SU R                  -  -  nUS-   S-  nS[        SS[        U5      S-  -   -  5      -
  n[        X4S	5      $ )
N©ç      ð?r\   r\   ©ç      à?r^   r^   ç(-DTû!	@r$   r^   r\   r   ç333333Ó?çš™™™™™é?)Úisinfr4   r2   ÚargÚpir5   r   )r@   rX   rd   rI   r   s        r   Údefault_color_functionre   o   s‰   € Ø
‡y�y�‡|�|ØØ
‡y�y�‡|�|ØØ	€BÜ	ˆs�w‰w�q‹zÓ	˜SŸV™VÑ	#¨¨#¯&©&©Ñ1€AØ	
ˆS‰�C‰€AØŒe�A�sœ3˜q›6 3™;‘Ñ'Ó(Ñ(€AÜ�a˜CÓ Ð r   )
)ç      ð¿©ç        rh   rh   )gffffffî¿)çš™™™™™¹?gš™™™™™É?r^   )g      à¿)rh   r^   r\   )gš™™™™™©¿)gš™™™™™Ù?ra   ra   )rh   r[   )gš™™™™™©?)r\   çÍÌÌÌÌÌì?r`   )r^   )rj   r^   rh   )gffffffî?)gffffffæ?ri   rh   )r\   rg   )ç       @rg   c                 ó¼  • U R                  U5      (       a  gU R                  U5      (       a  gSn[        U R                  U5      5      U-  n[	        [        US5      S5      n[        S[        [        5      5       H\  n[        U   S   U:”  d  M  [        US-
     u  nu  pgn[        U   u  n	u  p«nX5-
  X•-
  -  nXjU-
  U-  -   X{U-
  U-  -   XŒU-
  U-  -   4s  $    g )Nr[   r]   r_   r\   rf   r   r   )	rb   r4   r2   rc   ÚmaxÚminÚranger3   Úblue_orange_colors)r@   rX   rd   ÚwrP   rI   ÚraÚgaÚbar   ÚrbÚgbÚbbrU   s                 r   Úphase_color_functionrx   ‡   sÙ   € Ø
‡y�y�‡|�|ØØ
‡y�y�‡|�|ØØ	€BÜˆc�g‰g�a‹jÓ˜BÑ€AÜŒC��3‹K˜Ó€AÜ�1”SÔ+Ó,Ö-ˆÜ˜aÑ  Ñ# aÕ'Ü0°°1±Ñ5‰OˆA‰|�˜Ü0°Ñ3‰OˆA‰|�˜Ø‘˜™‘ˆAØ˜"‘u˜a‘i‘< ¨¡U¨A¡I¡¨r°b±5¸!±)©|Ð;Ò;ò .r   iÐ  Fc
                 ó  • Ub  US:X  a  U R                   nUS:X  a  U R                  nSSKn
U(       a  Sn	SnU	(       d!  U
R                  5       nUR	                  S5      n	Uu  pÍUu  pïXÜ-
  nXþ-
  n[        U R                  UU-  U-  5      S-   5      n[        U R                  UU-  U-  5      S-   5      nU
R                  XÍU5      nU
R                  XïU5      nU
R                  UUS45      n[        U5       Ho  n[        U5       H1  nU R                  UU   UU   5      n U" U" U5      5      nUUUU4'   M3     U(       d  ML  [        [        U5      S	-   [        U5      -   5        Mq     XÍXï4 Vs/ s H  n[        U5      PM     snu  pÍpïU	R                  UXÍXï4S
S9  U	R!                  S5        U	R#                  S5        U(       a(  U(       a  U
R%                  XxS9  gU
R'                  5         gg! U R                   a    Sn NÕf = fs  snf )ak  
Plots the given complex-valued function *f* over a rectangular part
of the complex plane specified by the pairs of intervals *re* and *im*.
For example::

    cplot(lambda z: z, [-2, 2], [-10, 10])
    cplot(exp)
    cplot(zeta, [0, 1], [0, 50])

By default, the complex argument (phase) is shown as color (hue) and
the magnitude is show as brightness. You can also supply a
custom color function (*color*). This function should take a
complex number as input and return an RGB 3-tuple containing
floats in the range 0.0-1.0.

Alternatively, you can select a builtin color function by passing
a string as *color*:

  * "default" - default color scheme
  * "phase" - a color scheme that only renders the phase of the function,
     with white for positive reals, black for negative reals, gold in the
     upper half plane, and blue in the lower half plane.

To obtain a sharp image, the number of points may need to be
increased to 100,000 or thereabout. Since evaluating the
function that many times is likely to be slow, the 'verbose'
option is useful to display progress.

.. note :: This function requires matplotlib (pylab).
NÚdefaultÚphaser   r   r   r#   r]   z of Úlower)ÚextentÚoriginzRe(z)zIm(z)r(   )re   rx   r*   r+   r,   ÚintÚsqrtÚlinspaceÚzerosr   Úmpcr   ÚprintÚstrr2   Úimshowr;   r<   r>   r?   )r@   rA   rS   rT   rD   ÚcolorÚverboserE   r)   rG   r*   rH   ÚreaÚrebÚimaÚimbÚdreÚdimÚMÚNr'   rV   rq   rK   r   rX   rR   rY   s                               r   Úcplotr‘   –   sø  € ð@ �}˜ Ó*Ø×*Ñ*ˆØ�ÓØ×(Ñ(ˆÛÞØˆØ
€CÞØ�l‰l‹nˆØ�‰˜sÓ#ˆØ�H€CØ�H€CØ
‰)€CØ
‰)€CÜˆC�H‰H�V˜C‘Z ‘^Ó$ QÑ&Ó'€AÜˆC�H‰H�V˜C‘Z ‘^Ó$ QÑ&Ó'€AØ�‰�s Ó#€AØ�‰�s Ó#€Að
 	�‰�Q˜˜1�IÓ€AÜ�AŽYˆÜ˜–ˆAØ—‘˜˜!™˜a ™dÓ#ˆAð$Ù™!˜A›$“K�ð ˆAˆa�ˆc‹Fñ ÷ ˆ7Ü”#�a“&˜6‘/¤C¨£FÑ*Ö+ñ ð .1°sÑ,@ÓAÒ,@ qœ% ž(Ñ,@ÑAÑ€CˆcØ‡K�K�˜3 SÐ.°w€KÑ?Ø‡O�O�GÔØ‡O�O�GÔÞ
ÞØ�M‰M˜$ˆMÒ(à�J‰J�Lð	 øð —?‘?ó $Ø#’ð$üò
 Bs   Ä"G1Å1H	Ç1HÈHéd   Tc
           	      ó^  • SSK n
SSKJn  U(       a  Sn	SnU	(       d+  U
R                  5       nUR                  R                  U5      n	Uu  pÞUu  nnXí-
  nUU-
  n[        U[        [        45      (       d  XD/nUu  nnU
R                  XÞU5      nU
R                  UUU5      n[        S5       Vs/ s H  nU
R                  UU45      PM     snu  nnn[        S5       Vs/ s H  nSS/PM	     snu  nnn[        U5       Hš  n[        U5       Hˆ  nU" U R                  UU   5      U R                  UU   5      5      n Uu  UUU4'   UUU4'   UUU4'   UUU4   U4UUU4   U4UUU4   U44 H$  u  nn UU S   :  a  UU S'   UU S   :”  d  M  UU S'   M&     MŠ     Mœ     U(       a  U	R                  UUUSSS9  OU	R                  UUUSSS9  U	R!                  S5        U	R#                  S5        U	R%                  S	5        U(       a½  UUU4 V s/ s H  n U S   U S   -
  PM     sn u  n!n"n#['        U!U"U#5      n$U!U$:  a)  U$U!-
  n%U	R)                  US   U%S
-  -
  US   U%S
-  -   5        U"U$:  a)  U$U"-
  n%U	R+                  US   U%S
-  -
  US   U%S
-  -   5        U#U$:  a)  U$U#-
  n%U	R-                  US   U%S
-  -
  US   U%S
-  -   5        U(       a(  U(       a  U
R/                  XxS9  gU
R1                  5         ggs  snf s  snf ! [         a     UU   UU   UsUUU4'   UUU4'   UUU4'    GNÒf = fs  sn f )aÞ  
Plots the surface defined by `f`.

If `f` returns a single component, then this plots the surface
defined by `z = f(x,y)` over the rectangular domain with
`x = u` and `y = v`.

If `f` returns three components, then this plots the parametric
surface `x, y, z = f(u,v)` over the pairs of intervals `u` and `v`.

For example, to plot a simple function::

    >>> from mpmath import *
    >>> f = lambda x, y: sin(x+y)*cos(y)
    >>> splot(f, [-pi,pi], [-pi,pi])    # doctest: +SKIP

Plotting a donut::

    >>> r, R = 1, 2.5
    >>> f = lambda u, v: [r*cos(u), (R+r*sin(u))*cos(v), (R+r*sin(u))*sin(v)]
    >>> splot(f, [0, 2*pi], [0, 2*pi])    # doctest: +SKIP

.. note :: This function requires matplotlib (pylab) 0.98.5.3 or higher.
r   Nr#   r   é   )ÚrstrideÚcstrider'   rV   rX   rk   r(   )r*   Úmpl_toolkits.mplot3dÚmplot3dr+   Úaxes3dÚAxes3Dr-   r/   r.   r�   r   r‚   ÚconvertÚ	TypeErrorÚplot_wireframeÚplot_surfacer;   r<   Ú
set_zlabelrm   Ú
set_xlim3dÚ
set_ylim3dÚ
set_zlim3dr>   r?   )&r@   rA   ÚurR   rD   Úkeep_aspectÚ	wireframerE   r)   rG   r*   r˜   rH   ÚuaÚubÚvaÚvbÚduÚdvr�   r�   rP   r'   rV   rX   ÚxabÚyabÚzabrK   r   ÚfdatarW   ÚcabÚdxÚdyÚdzÚmaxdÚdeltas&                                         r   Úsplotr¶   â   si  € ó4 Ý*ÞØˆØ
€CÞØ�l‰l‹nˆØ�~‰~×$Ñ$ SÓ)ˆØ�F€BØ�F€BˆØ	‰€BØ	ˆb‰€BÜ�fœt¤U˜m×,Ñ,ØÐ!ˆØ�D€A€qØ�‰�r˜qÓ!€AØ�‰�r˜2˜qÓ!€AÜ,2°1¬IÓ6ªI qˆu�{‰{˜A˜q˜6Ö"©IÑ6�G€A€qˆ!Ü%+¨A¤YÓ/¢Y �a˜“V¡YÑ/�M€CˆˆcÜ�AŽYˆÜ˜–ˆAÙ�c—k‘k ! A¡$Ó'¨¯©°Q°q±TÓ):Ó;ˆEð;Ø).Ñ&��!�A�#‘˜˜!˜A˜#™  ! A #¡ð ˜a ˜c™F C˜=¨1¨Q¨q¨S©6°3¨-¸!¸A¸a¸C¹&À#¸ÓG‘��3Ø�s˜1‘v“:Ø�C˜‘FØ�s˜1‘v•:Ø�C˜“Fó	 Hó ñ ö Ø×Ñ˜A˜q !¨Q¸ÐÒ:à×Ñ˜!˜Q ¨1°aÐÑ8Ø‡O�O�CÔØ‡O�O�CÔØ‡O�O�CÔÞØ25°s¸C±ÓA²¨#�c˜!‘f˜s 1™v”o±ÑA‰
ˆˆB�Ü�2�r˜2‹ˆØ�‹9Ø˜2‘IˆEØ�O‰O˜C ™F U¨S¡[Ñ0°#°a±&¸5À3¹;Ñ2FÔGØ�‹9Ø˜2‘IˆEØ�O‰O˜C ™F U¨S¡[Ñ0°#°a±&¸5À3¹;Ñ2FÔGØ�‹9Ø˜2‘IˆEØ�O‰O˜C ™F U¨S¡[Ñ0°#°a±&¸5À3¹;Ñ2FÔGÞ
ÞØ�M‰M˜$ˆMÒ(à�J‰J�Lð	 ùòC 7ùÚ/øô ó ;Ø)*¨1©¨q°©t°UÐ&��!�A�#‘˜˜!˜A˜#™  ! A #¤ð;üò Bs$   Â/K3Ã K8Ä?K=ÈL*Ë=&L'Ì&L')Ú__doc__Úcolorsysr   r   Úlibmpr   Úlibmp.backendr   Úobjectr	   r8   re   rp   rx   r‘   r¶   r   r   r   Ú<module>r¼      sÇ   ðñ÷ ,Ý  Ý !ôR˜6ô Rð ˜!�f 4°¸$ÀDØ˜4ôaòF	!òÐ ò<ð ˜�V  A ¨t¸4Ø˜ $¨TôJðX ˜�F˜r !˜f¨S¸dØ ¨$°TôPðf !Ð Ô Ø.DÐ Ô +Ø,@Ð Ô )Ø"Ð Ô Ø"Ð Õ r   