+
    ‹°³jï  ã                   ó  € ^ RI Ht ^ RIHt ^ RIHtHt ^ RIHtH	t	 ^ RI
Ht ^ RIHtHt ^ RIHt ^ RIHtHtHtHtHtHtHtHtHtHtHtHtHt ^ R	IH t   RRRRRRR
RR
RR RRRR
RR
/R llt!R t"R
R]! 4       3RR
/R llt#R
# )é    )ÚTuple)Úoo)ÚGtÚLt)ÚDummyÚSymbol)ÚAbs)ÚMinÚMax)ÚAnd)Ú
AssignmentÚAddAugmentedAssignmentÚbreak_Ú	CodeBlockÚDeclarationÚFunctionDefinitionÚPrintÚReturnÚScopeÚWhileÚVariableÚPointerÚreal)ÚisnanNÚrtolg¼‰Ø—²Ò¼<ÚdebugFÚitermaxÚcounterÚdelta_fnc                 ó4   € V ) V P                  V4      ,          # ©N)Údiff)ÚeÚxs   &&ÚY/home/luca/screen-checking/.venv/lib/python3.14/site-packages/sympy/codegen/algorithms.pyÚ<lambda>r&      s   € ÀaÀRÈÏÉÈqË	Æ\ó    ÚcseÚ
handle_nanÚboundsc               ó
  € Vf   \        4       p\        pRpMR pVP                  pV! W4      pV	'       dX   ^ RIHp	 V	! VP                  4       .4      w  pw  pV UUu. uF  w  pp\        VV4      NK  	  pppV\        VV4      .,          pM\        W>4      .pV
e,   V\        \        V4      \        V
\        4      4      .,          pV\        W4      .,          pVe6   V\        V\        \        W^ ,          4      V^,          4      4      .,          pV'       d2   \        W.RP                  VP                  V4      4      pVV.,          p\!        \#        V4      W$\#        V4      ,          ,           4      p\%        \'        V\(        \*        R7      4      .pVex   T;'       g    \        RR7      p\&        P,                  ! V^ 4      pVP/                  \%        V4      4       VP/                  \        V^4      4       \1        V\3        Wv4      4      p\        V\        V!  4      pTpV'       d6   VP/                  \        V.RP                  VP                  4      4      4       VV.,          pV! \        V!  4      # u uppi )	aí  Generates an AST for Newton-Raphson method (a root-finding algorithm).

Explanation
===========

Returns an abstract syntax tree (AST) based on ``sympy.codegen.ast`` for Netwon's
method of root-finding.

Parameters
==========

expr : expression
wrt : Symbol
    With respect to, i.e. what is the variable.
atol : number or expression
    Absolute tolerance (stopping criterion)
rtol : number or expression
    Relative tolerance (stopping criterion)
delta : Symbol
    Will be a ``Dummy`` if ``None``.
debug : bool
    Whether to print convergence information during iterations
itermax : number or expr
    Maximum number of iterations.
counter : Symbol
    Will be a ``Dummy`` if ``None``.
delta_fn: Callable[[Expr, Symbol], Expr]
    computes the step, default is newtons method. For e.g. Halley's method
    use delta_fn=lambda e, x: -2*e*e.diff(x)/(2*e.diff(x)**2 - e*e.diff(x, 2))
cse: bool
    Perform common sub-expression elimination on delta expression
handle_nan: Token
    How to handle occurrence of not-a-number (NaN).
bounds: Optional[tuple[Expr, Expr]]
    Perform optimization within bounds

Examples
========

>>> from sympy import symbols, cos
>>> from sympy.codegen.ast import Assignment
>>> from sympy.codegen.algorithms import newtons_method
>>> x, dx, atol = symbols('x dx atol')
>>> expr = cos(x) - x**3
>>> algo = newtons_method(expr, x, atol=atol, delta=dx)
>>> algo.has(Assignment(dx, -expr/expr.diff(x)))
True

References
==========

.. [1] https://en.wikipedia.org/wiki/Newton%27s_method

Údeltac                 ó   € V # r!   © )r$   s   &r%   r&   Ú newtons_method.<locals>.<lambda>P   s   € ™Ar'   )r(   z{}=%12.5g {}=%12.5g\n)ÚtypeÚvalueT)Úintegerz{}=%12.5g\n)r   r   ÚnameÚsympy.simplify.cse_mainr(   Úfactorr   r   r   r   r   r   r
   r   r   Úformatr   r	   r   r   r   r   ÚdeducedÚappendr   r   )ÚexprÚwrtÚatolr,   r   r   r   r   r   r(   r)   r*   ÚWrapperÚname_dÚ
delta_exprÚcsesÚredÚdumÚsub_eÚwhl_bdyÚprntÚreqÚdeclarsÚ	v_counterÚwhlÚblcks   &&&&$$$$$$$$              r%   Únewtons_methodrJ      s  € ðv ‚}Ü“ˆÜˆØ‰áˆØ—‘ˆá˜$Ó$€Jß
Ý/Ù˜J×-Ñ-Ó/Ð0Ó1‰ˆ‰fˆsÙ<@ÔA¹D©j¨c°5”:˜c 5Ö)¹DˆÑAØ”J˜u cÓ*Ð+Õ+‰ä˜eÓ0Ð1ˆØÒØ”Eœ% ›,¬	°*¼fÓ(EÓFÐGÕGˆØÔ& sÓ2Ð3Õ3€GØÒØ”J˜s¤C¬¨C¸µÓ(;¸VÀA½YÓ$GÓHÐIÕIˆßÜ�c�\Ð#;×#BÑ#BÀ3Ç8Á8ÈVÓ#TÓUˆØ�D�6ÕˆÜ
ŒS�‹Z˜¤S¨£X¥Õ-Ó
.€CÜœ8 E´¼BÔ?Ó@ÐA€GØÒØ×0Ð0œU¨4Ô0ˆÜ×$Ò$ W¨aÓ0ˆ	Ø�‰”{ 9Ó-Ô.Ø�‰Ô-¨g°qÓ9Ô:Ü�#”r˜'Ó+Ó,ˆÜ
�”Y Ñ(Ó
)€CØ€DßØ�‰”E˜3˜% ×!6Ñ!6°s·x±xÓ!@ÓAÔBØˆSˆE…M€DÙ”9˜dÑ#Ó$Ð$ùó3 Bs   ÁI?c                 ó¦   € \        V \        4      '       d   V P                  P                  p V # \        V \        4      '       d   V P                  p V # r!   )Ú
isinstancer   ÚvariableÚsymbolr   )Úargs   &r%   Ú
_symbol_ofrP   s   sB   € Ü�#”{×#Ò#Ø�l‰l×!Ñ!ˆð €Jô 
�Cœ×	"Ò	"Ø�j‰jˆØ€Jr'   Únewtonr,   c          	     ó@  € Vf   V3pV Uu/ uFL  p\        V\        4      '       g   K  VP                  \        RVP                  P                  ,          4      bKN  	  ppVf6   \        RVP                  ,           4      pV P                  V4      '       d   Rp\        W3RV/VB P                  V4      p	\        V	\        4      '       d   V	P                  p	V P                  P                  V Uu0 uF  p\        V4      kK  	  up4      p
V
'       d0   \        RRP                  \        \         V
4      4      ,          4      h\"        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      p\%        V	\'        V4      4      p\)        \*        W;WÄR7      # u upi u upi )	aY  Generates an AST for a function implementing the Newton-Raphson method.

Parameters
==========

expr : expression
wrt : Symbol
    With respect to, i.e. what is the variable
params : iterable of symbols
    Symbols appearing in expr that are taken as constants during the iterations
    (these will be accepted as parameters to the generated function).
func_name : str
    Name of the generated function.
attrs : Tuple
    Attribute instances passed as ``attrs`` to ``FunctionDefinition``.
\*\*kwargs :
    Keyword arguments passed to :func:`sympy.codegen.algorithms.newtons_method`.

Examples
========

>>> from sympy import symbols, cos
>>> from sympy.codegen.algorithms import newtons_method_function
>>> from sympy.codegen.pyutils import render_as_module
>>> x = symbols('x')
>>> expr = cos(x) - x**3
>>> func = newtons_method_function(expr, x)
>>> py_mod = render_as_module(func)  # source code as string
>>> namespace = {}
>>> exec(py_mod, namespace, namespace)
>>> res = eval('newton(0.5)', namespace)
>>> abs(res - 0.865474033102) < 1e-12
True

See Also
========

sympy.codegen.algorithms.newtons_method

Nz(*%s)Úd_r,   zMissing symbols in params: %sz, c              3   óB   "  € T F  p\        V\        4      x € K  	  R # 5ir!   )r   r   )Ú.0Úps   & r%   Ú	<genexpr>Ú*newtons_method_function.<locals>.<genexpr>²   s   é € Ð6©v¨!”H˜Q¤×%Ð%«vùs   ‚)Úattrs)rL   r   rN   r   r3   ÚhasrJ   Úxreplacer   ÚbodyÚfree_symbolsÚ
differencerP   Ú
ValueErrorÚjoinÚmapÚstrÚtupler   r   r   r   )r9   r:   ÚparamsÚ	func_namerY   r,   ÚkwargsrV   Úpointer_subsÚalgoÚnot_in_paramsrF   r\   s   &&&&&$,      r%   Únewtons_method_functionrj   {   sJ  € ðR ‚~Ø�ˆá#ó?Ù#˜¤z°!´W×'=ô >�A—H‘Hœf W¨q¯x©x¯}©}Õ%<Ó=Ò=Ù#ð ð ?à‚}Ü�t˜cŸh™h•Ó'ˆØ�8‰8�E�?Š?ØˆEÜ˜$Ñ;¨5Ð;°FÑ;×DÑDÀ\ÓR€DÜ�$œ×ÒØ�y‰yˆØ×%Ñ%×0Ñ0ÉÓ1PÉÀA´*¸Q¶-ÉÑ1PÓQ€MßÜÐ8¸4¿9¹9ÄSÌÈmÓE\Ó;]Õ]Ó^Ð^ßŒeÑ6©vÓ6�e‰eÑ6©vÓ6Ó6€GÜ�Tœ6 #›;Ó'€DÜœd I¸ÔJÐJùò?ùò 2Qs   ŒF©5FÃ1F)gê-�™—q=N)$Úsympy.core.containersr   Úsympy.core.numbersr   Úsympy.core.relationalr   r   Úsympy.core.symbolr   r   Ú$sympy.functions.elementary.complexesr	   Ú(sympy.functions.elementary.miscellaneousr
   r   Úsympy.logic.boolalgr   Úsympy.codegen.astr   r   r   r   r   r   r   r   r   r   r   r   r   Úsympy.codegen.cfunctionsr   rJ   rP   rj   r.   r'   r%   Ú<module>rt      s¤   ðÝ 'Ý !ß *ß -Ý 4ß =Ý #÷÷ ÷ õ õ +à Uñ`%¸eð `%È5ð `%Øð`%Ø)-ð`%Ù8Qð`%àð`%à)-ð`%ð õ`%òFð /3¸hÉeËgñ 9KÐ`d÷ 9Kr'   