rubysl-bigdecimal 1.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,38 +0,0 @@
1
- #!/usr/local/bin/ruby
2
-
3
- #
4
- # nlsolve.rb
5
- # An example for solving nonlinear algebraic equation system.
6
- #
7
-
8
- require "bigdecimal"
9
- require "bigdecimal/newton"
10
- include Newton
11
-
12
- class Function
13
- def initialize()
14
- @zero = BigDecimal::new("0.0")
15
- @one = BigDecimal::new("1.0")
16
- @two = BigDecimal::new("2.0")
17
- @ten = BigDecimal::new("10.0")
18
- @eps = BigDecimal::new("1.0e-16")
19
- end
20
- def zero;@zero;end
21
- def one ;@one ;end
22
- def two ;@two ;end
23
- def ten ;@ten ;end
24
- def eps ;@eps ;end
25
- def values(x) # <= defines functions solved
26
- f = []
27
- f1 = x[0]*x[0] + x[1]*x[1] - @two # f1 = x**2 + y**2 - 2 => 0
28
- f2 = x[0] - x[1] # f2 = x - y => 0
29
- f <<= f1
30
- f <<= f2
31
- f
32
- end
33
- end
34
- f = BigDecimal::limit(100)
35
- f = Function.new
36
- x = [f.zero,f.zero] # Initial values
37
- n = nlsolve(f,x)
38
- p x
@@ -1,20 +0,0 @@
1
- #!/usr/local/bin/ruby
2
-
3
- #
4
- # pi.rb
5
- #
6
- # Calculates 3.1415.... (the number of times that a circle's diameter
7
- # will fit around the circle) using J. Machin's formula.
8
- #
9
-
10
- require "bigdecimal"
11
- require "bigdecimal/math.rb"
12
-
13
- include BigMath
14
-
15
- if ARGV.size == 1
16
- print "PI("+ARGV[0]+"):\n"
17
- p PI(ARGV[0].to_i)
18
- else
19
- print "TRY: ruby pi.rb 1000 \n"
20
- end