+
    i                        ^ 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   &&x/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/codegen/algorithms.py<lambda>r&      s    aR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fs<@ADjc5:c5)DAJuc*++e01E%,	*f(EFGG&s233GJsCC(;VAY$GHIIc\#;#B#B388V#TUD6
SZSX-
.C8EB?@AG00U40$$Wa0	{9-.-gq9:#r'+,
Y(
)CDE3%!6!6sxx!@ABSEMD9d#$$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    #{##ll!! J 
C	"	"jj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;WR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     6v!HQ%%vs   )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'= >AHHfWqxx}}%<==#  ?}tchh'88E??E$;5;F;DD\RD$yy%%001PA*Q-1PQM8499SmE\;]]^^e6v6ee6v66GT6#;'DdI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 /3heg 9K`d 9Kr'   