9
9
10
10
import math
11
11
12
+
12
13
class HyperbolicFunction (BuiltinFunction ):
13
14
r"""
14
15
Abstract base class for the functions defined in this file.
@@ -37,8 +38,8 @@ def __init__(self, name, latex_name=None, conversions=None,
37
38
38
39
sage: from sage.functions.hyperbolic import HyperbolicFunction
39
40
sage: class Barh(HyperbolicFunction):
40
- ... def __init__(self):
41
- ... HyperbolicFunction.__init__(self, 'barh')
41
+ ....: def __init__(self):
42
+ ....: HyperbolicFunction.__init__(self, 'barh')
42
43
sage: barh = Barh()
43
44
sage: barh(x)
44
45
barh(x)
@@ -53,8 +54,8 @@ def _evalf_(self, x, parent=None, algorithm=None):
53
54
54
55
sage: from sage.functions.hyperbolic import HyperbolicFunction
55
56
sage: class Fooh(HyperbolicFunction):
56
- ... def __init__(self):
57
- ... HyperbolicFunction.__init__(self, 'fooh',evalf_float=lambda x: 2*x)
57
+ ....: def __init__(self):
58
+ ....: HyperbolicFunction.__init__(self, 'fooh',evalf_float=lambda x: 2*x)
58
59
sage: fooh = Fooh()
59
60
sage: fooh(float(5))
60
61
10.0
@@ -71,6 +72,7 @@ def _evalf_(self, x, parent=None, algorithm=None):
71
72
return self ._evalf_float (x )
72
73
return getattr (x , self .name ())()
73
74
75
+
74
76
class Function_sinh (GinacFunction ):
75
77
def __init__ (self ):
76
78
r"""
@@ -106,6 +108,7 @@ def __init__(self):
106
108
107
109
sinh = Function_sinh ()
108
110
111
+
109
112
class Function_cosh (GinacFunction ):
110
113
def __init__ (self ):
111
114
r"""
@@ -191,6 +194,7 @@ def __init__(self):
191
194
192
195
tanh = Function_tanh ()
193
196
197
+
194
198
class Function_coth (HyperbolicFunction ):
195
199
def __init__ (self ):
196
200
r"""
@@ -213,10 +217,10 @@ def __init__(self):
213
217
HyperbolicFunction .__init__ (self , "coth" , latex_name = r"\coth" ,
214
218
evalf_float = lambda x : 1 / math .tanh (x ))
215
219
216
- def _eval_ (self , x ):
220
+ def _eval_ (self , x ):
217
221
"""
218
222
EXAMPLES::
219
-
223
+
220
224
sage: coth(0)
221
225
+Infinity
222
226
sage: coth(pi*I)
@@ -233,9 +237,9 @@ def _eval_ (self, x):
233
237
if x .is_zero ():
234
238
return Infinity
235
239
if isinstance (x , Expression ):
236
- x = 2 * x / pi / I
237
- if x .is_integer ():
238
- if ZZ (x ) % 2 == 1 :
240
+ y = 2 * x / pi / I
241
+ if y .is_integer ():
242
+ if ZZ (y ) % 2 == 1 :
239
243
return 0
240
244
else :
241
245
return Infinity
@@ -265,6 +269,7 @@ def _derivative_(self, *args, **kwds):
265
269
266
270
coth = Function_coth ()
267
271
272
+
268
273
class Function_sech (HyperbolicFunction ):
269
274
def __init__ (self ):
270
275
r"""
@@ -287,10 +292,10 @@ def __init__(self):
287
292
HyperbolicFunction .__init__ (self , "sech" , latex_name = r"{\rm sech}" ,
288
293
evalf_float = lambda x : 1 / math .cosh (x ))
289
294
290
- def _eval_ (self , x ):
295
+ def _eval_ (self , x ):
291
296
"""
292
297
EXAMPLES::
293
-
298
+
294
299
sage: sech(0)
295
300
1
296
301
sage: sech(pi*I)
@@ -307,12 +312,12 @@ def _eval_ (self, x):
307
312
if x .is_zero ():
308
313
return 1
309
314
if isinstance (x , Expression ):
310
- x = 2 * x / pi / I
311
- if x .is_integer ():
312
- if ZZ (x ) % 2 == 1 :
315
+ y = 2 * x / pi / I
316
+ if y .is_integer ():
317
+ if ZZ (y ) % 2 == 1 :
313
318
return Infinity
314
319
else :
315
- return ZZ (- 1 )** ZZ (x / 2 )
320
+ return ZZ (- 1 ) ** ZZ (y / 2 )
316
321
317
322
def _eval_numpy_ (self , x ):
318
323
"""
@@ -362,10 +367,10 @@ def __init__(self):
362
367
HyperbolicFunction .__init__ (self , "csch" , latex_name = r"{\rm csch}" ,
363
368
evalf_float = lambda x : 1 / math .sinh (x ))
364
369
365
- def _eval_ (self , x ):
370
+ def _eval_ (self , x ):
366
371
"""
367
372
EXAMPLES::
368
-
373
+
369
374
sage: csch(0)
370
375
+Infinity
371
376
sage: csch(pi*I)
@@ -380,10 +385,10 @@ def _eval_ (self, x):
380
385
if x .is_zero ():
381
386
return Infinity
382
387
if isinstance (x , Expression ):
383
- x = 2 * x / pi / I
384
- if x .is_integer ():
385
- if ZZ (x ) % 2 == 1 :
386
- return ZZ (- 1 )** ZZ ((x + 1 ) / 2 ) * I
388
+ y = 2 * x / pi / I
389
+ if y .is_integer ():
390
+ if ZZ (y ) % 2 == 1 :
391
+ return ZZ (- 1 ) ** ZZ ((y + 1 ) / 2 ) * I
387
392
else :
388
393
return Infinity
389
394
@@ -417,6 +422,7 @@ def _derivative_(self, *args, **kwds):
417
422
# Inverse hyperbolic functions #
418
423
################################
419
424
425
+
420
426
class Function_arcsinh (GinacFunction ):
421
427
def __init__ (self ):
422
428
r"""
@@ -474,6 +480,7 @@ def __init__(self):
474
480
475
481
arcsinh = asinh = Function_arcsinh ()
476
482
483
+
477
484
class Function_arccosh (GinacFunction ):
478
485
def __init__ (self ):
479
486
r"""
@@ -553,6 +560,7 @@ def __init__(self):
553
560
554
561
arccosh = acosh = Function_arccosh ()
555
562
563
+
556
564
class Function_arctanh (GinacFunction ):
557
565
def __init__ (self ):
558
566
r"""
@@ -608,6 +616,7 @@ def __init__(self):
608
616
609
617
arctanh = atanh = Function_arctanh ()
610
618
619
+
611
620
class Function_arccoth (HyperbolicFunction ):
612
621
def __init__ (self ):
613
622
r"""
@@ -668,6 +677,7 @@ def _derivative_(self, *args, **kwds):
668
677
669
678
arccoth = acoth = Function_arccoth ()
670
679
680
+
671
681
class Function_arcsech (HyperbolicFunction ):
672
682
def __init__ (self ):
673
683
r"""
@@ -718,6 +728,7 @@ def _derivative_(self, *args, **kwds):
718
728
719
729
arcsech = asech = Function_arcsech ()
720
730
731
+
721
732
class Function_arccsch (HyperbolicFunction ):
722
733
def __init__ (self ):
723
734
r"""
0 commit comments