@@ -2376,7 +2376,7 @@ def derivative(self, ex, operator):
23762376 return operator (* [self (_ ) for _ in ex .operands ()])
23772377
23782378class Exponentialize (ExpressionTreeWalker ):
2379- # Implementation note : this code is executed once at first
2379+ # Implementation note: this code is executed once at first
23802380 # reference in the code using it, therefore avoiding rebuilding
23812381 # the same canned results dictionary at each call.
23822382 from sage .functions .hyperbolic import sinh , cosh , sech , csch , tanh , coth
@@ -2387,7 +2387,7 @@ class Exponentialize(ExpressionTreeWalker):
23872387 from sage .rings .integer import Integer
23882388 from sage .symbolic .ring import SR
23892389 from sage .calculus .var import function
2390- half = Integer (1 )/ Integer (2 )
2390+ half = Integer (1 ) / Integer (2 )
23912391 two = Integer (2 )
23922392 x = SR .var ("x" )
23932393 CircDict = {
@@ -2405,26 +2405,29 @@ class Exponentialize(ExpressionTreeWalker):
24052405 coth : (- (exp (- x ) + exp (x ))/ (exp (- x ) - exp (x ))).function (x )
24062406 }
24072407 Circs = list (CircDict .keys ())
2408+
24082409 def __init__ (self , ex ):
24092410 """
24102411 A class that walks a symbolic expression tree and replace circular
24112412 and hyperbolic functions by their respective exponential
24122413 expressions.
24132414
2414- EXAMPLES ::
2415+ EXAMPLES::
24152416
24162417 sage: from sage.symbolic.expression_conversions import Exponentialize
24172418 sage: d=Exponentialize(sin(x))
24182419 sage: d(sin(x))
24192420 -1/2*I*e^(I*x) + 1/2*I*e^(-I*x)
24202421 sage: d(cosh(x))
24212422 1/2*e^(-x) + 1/2*e^x
2422-
24232423 """
24242424 self .ex = ex
2425+
24252426 def composition (self , ex , op ):
2426- """
2427- EXAMPLES ::
2427+ r"""
2428+ Return the composition of ``self`` with ``ex`` by ``op``.
2429+
2430+ EXAMPLES::
24282431
24292432 sage: x = SR.var("x")
24302433 sage: from sage.symbolic.expression_conversions import Exponentialize
@@ -2441,14 +2444,15 @@ def composition(self, ex, op):
24412444
24422445class DeMoivre (ExpressionTreeWalker ):
24432446 def __init__ (self , ex , force = False ):
2444- """
2447+ r """
24452448 A class that walks a symbolic expression tree and replaces
24462449 occurences of complex exponentials (optionally, all
24472450 exponentials) by their respective trigonometric expressions.
24482451
2449- INPUT::
2452+ INPUT:
24502453
2451- - ``force`` -- Boolean (default is False) : replace ``exp(x)`` with ``cosh(x) + sinh(x)``.
2454+ - ``force`` -- boolean (default: ``False``); replace `\exp(x)`
2455+ with `\cosh(x) + \sinh(x)`
24522456
24532457 EXAMPLES::
24542458
@@ -2459,10 +2463,12 @@ def __init__(self, ex, force=False):
24592463 (cos(b) + I*sin(b))*e^a
24602464 """
24612465 self .ex = ex
2462- self .force = force
2466+ self .force = force
24632467
24642468 def composition (self , ex , op ):
24652469 """
2470+ Return the composition of ``self`` with ``ex`` by ``op``.
2471+
24662472 EXAMPLES::
24672473
24682474 sage: x, a, b = SR.var('x, a, b')
@@ -2473,15 +2479,16 @@ def composition(self, ex, op):
24732479 sage: s.composition(q, q.operator())
24742480 (cos(b) + I*sin(b))*e^a
24752481 """
2476- from sage .functions .hyperbolic import sinh , cosh
24772482 from sage .functions .log import exp
2478- from sage .functions .trig import sin , cos
2479- from sage .rings .imaginary_unit import I
2480- from sage .symbolic .ring import SR
24812483 if op is not exp :
24822484 # return super(DeMoivre, self).composition(ex, op)
2483- return op (* [self (_ ) for _ in ex .operands ()])
2484- arg = self (ex .operands ()[0 ])()
2485+ return op (* [self (oper ) for oper in ex .operands ()])
2486+
2487+ from sage .rings .imaginary_unit import I
2488+ from sage .symbolic .ring import SR
2489+ from sage .functions .hyperbolic import sinh , cosh
2490+ from sage .functions .trig import sin , cos
2491+ arg = self (ex .operands ()[0 ])()
24852492 w0 , w1 = (SR .wild (u ) for u in range (2 ))
24862493 D = arg .match (w0 + I * w1 )
24872494 if D is not None :
0 commit comments