Changeset 7819:256fb33dd86c
- Timestamp:
- 12/20/07 17:35:04 (5 years ago)
- Branch:
- default
- Parents:
- 7817:e526ad576440 (diff), 7818:b2d99e388e5c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 2 edited
-
sage/calculus/calculus.py (modified) (3 diffs)
-
sage/calculus/calculus.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/calculus/calculus.py
r7810 r7819 5537 5537 class Function_atanh(PrimitiveFunction): 5538 5538 """ 5539 The inverse of the hyperbolic tan efunction.5539 The inverse of the hyperbolic tangent function. 5540 5540 5541 5541 EXAMPLES: … … 5559 5559 _syms['atanh'] = atanh 5560 5560 5561 class Function_acoth(PrimitiveFunction): 5562 """ 5563 The inverse of the hyperbolic cotangent function. 5564 5565 EXAMPLES: 5566 sage: acoth(2.) 5567 0.549306144334055 5568 sage: acoth(2) 5569 acoth(2) 5570 sage: acoth(1 + I*1.0) 5571 0.402359478108525 - 0.553574358897045*I 5572 """ 5573 def _repr_(self, simplify=True): 5574 return "acoth" 5575 5576 def _latex_(self): 5577 return "\\coth^{-1}" 5578 5579 def _approx_(self, x): 5580 return float(pari(float(1/x)).atanh()) 5581 5582 acoth = Function_acoth() 5583 _syms['acoth'] = acoth 5584 5585 class Function_asech(PrimitiveFunction): 5586 """ 5587 The inverse of the hyperbolic secant function. 5588 5589 EXAMPLES: 5590 sage: asech(.5) 5591 1.316957896924817 5592 sage: asech(1/2) 5593 asech(1/2) 5594 sage: asech(1 + I*1.0) 5595 0.530637530952518 - 1.118517879643706*I 5596 """ 5597 def _repr_(self, simplify=True): 5598 return "asech" 5599 5600 def _latex_(self): 5601 return "\\sech^{-1}" 5602 5603 def _approx_(self, x): 5604 return float(pari(float(1/x)).acosh()) 5605 5606 asech = Function_asech() 5607 _syms['asech'] = asech 5608 5609 class Function_acsch(PrimitiveFunction): 5610 """ 5611 The inverse of the hyperbolic cosecant function. 5612 5613 EXAMPLES: 5614 sage: acsch(2.) 5615 0.481211825059603 5616 sage: acsch(2) 5617 acsch(2) 5618 sage: acsch(1 + I*1.0) 5619 0.530637530952518 - 0.452278447151191*I 5620 """ 5621 def _repr_(self, simplify=True): 5622 return "acsch" 5623 5624 def _latex_(self): 5625 return "\\csch^{-1}" 5626 5627 def _approx_(self, x): 5628 return float(pari(float(1/x)).asinh()) 5629 5630 acsch = Function_acsch() 5631 _syms['acsch'] = acsch 5632 5561 5633 class Function_acos(PrimitiveFunction): 5562 5634 """ … … 5607 5679 atan = Function_atan() 5608 5680 _syms['atan'] = atan 5681 5682 class Function_acot(PrimitiveFunction): 5683 """ 5684 The arccotangent function. 5685 5686 EXAMPLES: 5687 sage: acot(1/2) 5688 acot(1/2) 5689 sage: RDF(acot(1/2)) 5690 1.10714871779 5691 sage: acot(1 + I) 5692 acot(I + 1) 5693 """ 5694 def _repr_(self, simplify=True): 5695 return "acot" 5696 5697 def _latex_(self): 5698 return "\\cot^{-1}" 5699 5700 def _approx_(self, x): 5701 return math.pi/2 - math.atan(x) 5702 5703 acot = Function_acot() 5704 _syms['acot'] = acot 5705 5706 class Function_acsc(PrimitiveFunction): 5707 """ 5708 The arccosecant function. 5709 5710 EXAMPLES: 5711 sage: acsc(2) 5712 acsc(2) 5713 sage: RDF(acsc(2)) 5714 0.523598775598 5715 sage: acsc(1 + I) 5716 acsc(I + 1) 5717 """ 5718 def _repr_(self, simplify=True): 5719 return "acsc" 5720 5721 def _latex_(self): 5722 return "\\csc^{-1}" 5723 5724 def _approx_(self, x): 5725 return math.asin(1/x) 5726 5727 acsc = Function_acsc() 5728 _syms['acsc'] = acsc 5729 5730 class Function_asec(PrimitiveFunction): 5731 """ 5732 The arcsecant function. 5733 5734 EXAMPLES: 5735 sage: asec(2) 5736 asec(2) 5737 sage: RDF(asec(2)) 5738 1.0471975512 5739 sage: asec(1 + I) 5740 asec(I + 1) 5741 """ 5742 def _repr_(self, simplify=True): 5743 return "asec" 5744 5745 def _latex_(self): 5746 return "\\sec^{-1}" 5747 5748 def _approx_(self, x): 5749 return math.acos(1/x) 5750 5751 asec = Function_asec() 5752 _syms['asec'] = asec 5609 5753 5610 5754 -
sage/calculus/calculus.py
r7818 r7819 1997 1997 There is also a function \code{numerical_integral} that implements 1998 1998 numerical integration using the GSL C library. It is potentially 1999 much faster and applies to arbitrary user defined functions. 1999 much faster and applies to arbitrary user defined functions. 2000 2001 Also, there are limits to the precision that Maxima can compute 2002 the integral to due to limitations in quadpack. 2003 2004 sage: f = x 2005 sage: f = f.nintegral(x,0,1,1e-14) 2006 Traceback (most recent call last): 2007 ... 2008 ValueError: Maxima (via quadpack) cannot compute the integral to that precision 2000 2009 2001 2010 EXAMPLES: … … 2049 2058 syntax. 2050 2059 """ 2051 v = self._maxima_().quad_qags(var(x), 2060 try: 2061 v = self._maxima_().quad_qags(var(x), 2052 2062 a, b, desired_relative_error, 2053 2063 maximum_num_subintervals) 2064 except TypeError, err: 2065 if "ERROR NUMBER = 6" in str(err): 2066 raise ValueError, "Maxima (via quadpack) cannot compute the integral to that precision" 2067 else: 2068 raise TypeError, err 2069 2054 2070 return float(v[0]), float(v[1]), Integer(v[2]), Integer(v[3]) 2055 2071 … … 2459 2475 sage: v = 0.004*(9600*e^(-(1200*t)) - 2400*e^(-(300*t))) 2460 2476 sage: v.find_root(0, 0.002) 2461 0.001540327067911417 82477 0.001540327067911417... 2462 2478 2463 2479 sage: a = .004*(8*e^(-(300*t)) - 8*e^(-(1200*t)))*(720000*e^(-(300*t)) - 11520000*e^(-(1200*t))) +.004*(9600*e^(-(1200*t)) - 2400*e^(-(300*t)))^2 … … 2472 2488 However \code{find_root} works beautifully: 2473 2489 sage: a.find_root(0,0.002) 2474 0.0004110514049349341 12490 0.0004110514049349341... 2475 2491 """ 2476 2492 a = float(a); b = float(b)
Note: See TracChangeset
for help on using the changeset viewer.
