home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e032 / 3.ddi / FILES / PROGRAMM.PAK / CONSTANT.M < prev    next >
Encoding:
Text File  |  1992-07-29  |  903 b   |  34 lines

  1.  
  2. (*********************************************************************
  3.  
  4.         Adapted from
  5.         Roman E. Maeder: Programming in Mathematica,
  6.         Second Edition, Addison-Wesley, 1991.
  7.  
  8.  *********************************************************************)
  9.  
  10.  
  11. BeginPackage["NumericalMath`Constants`"]
  12.  
  13. Constants::usage = "Constants.m defines rules for approximate arithmetic with the
  14.     mathematical constants Pi, Degree, GoldenRatio, E, EulerGamma and Catalan."
  15.  
  16. Begin["`Private`"]
  17.  
  18. constantList = {Pi, Degree, GoldenRatio, E, EulerGamma, Catalan}
  19.  
  20. protected = Unprotect[Evaluate[constantList]]
  21.  
  22. DefineRules[const_Symbol] := (
  23.     const/: const + r_ := N[const, Accuracy[r]] + r /; Accuracy[r] < Infinity;
  24.     const/: const * r_ := N[const, Precision[r]] * r /; Precision[r] < Infinity
  25.     )
  26.  
  27. DefineRules /@ constantList
  28.  
  29. Protect[Evaluate[protected]]
  30.  
  31. End[]
  32.  
  33. EndPackage[]
  34.