appmath 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,126 @@
1
+ The Ruby-gem appmath (for applied mathematics)
2
+
3
+ implements arbitrary precision mathematics in a form
4
+ which is convenient to use. As a reality test of the
5
+ underying ideas it applies this arbitrary precision
6
+ programming scheme to linear algebra (including
7
+ singular value decomposition and Penrose inverse
8
+ of real matrices), graphical representation of functions,
9
+ and physical simuations (2 dimensional Kepler motion).
10
+
11
+ The origin and motivation of the work becomes clear
12
+ from the follwing note that I sent out to the
13
+ Ruby-Talk mailing list and which is placed in Ruby Forum
14
+ under the heading
15
+
16
+ Proposing an arbitrary precision class building on
17
+ BigDecimal and being derived from Numeric.
18
+
19
+
20
+ Dear Ruby commuity,
21
+
22
+ this note deals with arbitrary precision arithmetics and Ruby
23
+ module BigMath and Ruby class BigDecimal.
24
+
25
+ So we are dealing with the mind children of Shigeo Kobayashi, and
26
+ my first action in promoting my proposed addition to BigMath was
27
+ to comunicate it to Shigeo.
28
+
29
+ His reply ends in the sentences:
30
+
31
+ 'The only advice I can give you at this moment, is to annouce your
32
+ excelent work to Ruby community(open to any user).
33
+ ...
34
+ I (and any Ruby user ) will be happy if your work is incorporated into
35
+ the BigMath library.'
36
+
37
+ This work defines and tests a wrapper class for Shigeo's class BigDecimal.
38
+ This wrapper makes the class fit into the framework of the standard Ruby
39
+ number classes Fixnum, Bignum, and Float by having
40
+ Numeric
41
+ as its base class. The name which I propose for this class is
42
+ R (which is standard mathematical usage),
43
+ other names that I considered were
44
+ Real, BigReal, BigR.
45
+
46
+ The next unifying structural property of R ( besides R < Numeric) is that
47
+ it implements as member functions all the mathematical functions
48
+ sqrt, hypot, sin, ... atan2, ... , erf, erfc
49
+ which module Math implements for class Float.
50
+
51
+ This is an interesting point:
52
+ Although in any OO-language terms containing calls of methods (member functions)
53
+ are cleaner and easier to read than calls of non-member functions, actual
54
+ language definitions prefer sin(x) to x.sin. Be this as it is, my class
55
+ R allows to write
56
+ diff = x.sin**2 + x.cos**2 - 1
57
+ which is very small for, say,
58
+ x = R.new("1.23456789E123")
59
+ For this to work, one obviously needs to work with more than
60
+ the 123 decimals which come in already with the integer part of x.
61
+ So, for this computation, the default value of 40 decimals is too small.
62
+ We may set a sufficient accuracy by
63
+ R.dig = 1000
64
+ On my system (an off-the shelf laptop) it takes then 6.7 seconds
65
+ to find diff.abs.log10.round as -876.
66
+
67
+ Algorithms for these mathematical functions which are suitable for
68
+ arbitrary precision are implemented in BigMath and BigDecimal based on
69
+ everywhere convergent power series expansions. Although such expansions -
70
+ take the well-knwn one for exp(x) as a prime example - converge by the
71
+ exponential growth of the denominators of the generic series term,
72
+ the growth of x^n may dominate the result for many, many, terms in the
73
+ early live of the series. So, such expansions are convergent rapidly only if
74
+ |x| < 1. What I did was to figure out the mathematical identities that
75
+ allow to reduce computing x.f for arbitrary x to fuction evalutions at
76
+ auxiliar arguments y satisfying |y| < 1. What is needed here, hardly
77
+ transcends the tricks which people of my generation had to exercise at school
78
+ when working with logarithmic, exponential, and trigonometric functions
79
+ by means of printed tables instead of pocket calclators.
80
+
81
+ Of course, the question how to implement these functions by means of algorithms
82
+ is independent of the question whether to use member functions or non-member
83
+ functions in their definition.
84
+ However, the member function choice suggests a way of coping with
85
+ the number of allowed decimal places which is used in class R:
86
+ R has a class variable @@dig, the value of which (default is 40) controls the actual
87
+ execution of any member function. It is not necessary to be aware of the fact that
88
+ 'deep inside' Shigeo's powers series algorithms different numbers of decimal
89
+ places may be used, according to the needs of the algorithm.
90
+
91
+ This may suffice as a first presentation of class R.
92
+
93
+ A complete package of Ruby code and rdoc-generated documentation can be found on
94
+ (and freely downloaded from)
95
+
96
+ www.ulrichmutze.de
97
+
98
+ where the section
99
+ Free Ruby code
100
+ is the one which matters.
101
+
102
+ Every comment and suggestion for modification is wellcome!
103
+
104
+ Especially those that help to relate the present proposal to other projects
105
+ that add to he strength of Ruby as a tool in scientific computing.
106
+
107
+ Presently my idea is to make R a part of BigMath (it is a part of my
108
+ module AppMath, applied mathematics, in my present implementation) and to
109
+ become informed about the expectations that users of the BigMath library
110
+ may have concerning an arbitrary precision version of Float (which R in effect is).
111
+
112
+ Ulrich
113
+
114
+ Further, file rnum.rb of the present package contains a full description
115
+ of the scope of this gem.
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appmath
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ulrich Mutze
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-21 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Arbitrary precision mathematics with application to real and complex linear algebra, graphical representation of functions, and 2D Kepler motion
17
+ email: ulrichmutze@aol.com
18
+ executables:
19
+ - rnum_app.rb
20
+ - linalg_app.rb
21
+ - kepler_2d_app.rb
22
+ extensions: []
23
+
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - bin/rnum_app.rb
28
+ - bin/linalg_app.rb
29
+ - bin/kepler_2d_app.rb
30
+ - lib/rnum.rb
31
+ - lib/cnum.rb
32
+ - lib/float_ext.rb
33
+ - lib/appmath_basics.rb
34
+ - lib/interval.rb
35
+ - lib/graph.rb
36
+ - lib/linalg.rb
37
+ - lib/kepler_2d.rb
38
+ - lib/random.rb
39
+ - gpl-3.0.txt
40
+ - readme.txt
41
+ has_rdoc: true
42
+ homepage: http://www.ulrichmutze.de
43
+ post_install_message:
44
+ rdoc_options:
45
+ - -a
46
+ - -N
47
+ - -S
48
+ - --title
49
+ - Applied Mathematics API documentation
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ requirements: []
65
+
66
+ rubyforge_project: appmath
67
+ rubygems_version: 1.3.1
68
+ signing_key:
69
+ specification_version: 2
70
+ summary: Arbitrary precision mathematics
71
+ test_files: []
72
+