File: testmath2.rb

package info (click to toggle)
ruby-narray 0.6.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 468 kB
  • sloc: ansic: 4,498; ruby: 1,329; python: 91; makefile: 7
file content (46 lines) | stat: -rw-r--r-- 573 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require "narray"
include NMath

def testm x,name
  f = "a#{name}(#{name}(x))"
  print "\n### #{f} ###\n"
  y = eval(f)
  p y
  #d = x-y
  #p d.abs
end

PI=Math::PI

i = NArray.complex(1)
i.imag=1

n=7
x = NArray.complex(n).random!(1)
x.imag= NArray.float(n).random!(1)

p x
testm x,"sin"
testm x,"cos"
testm x,"tan"
testm x,"sinh"
testm x,"cosh"
testm x,"tanh"
testm x,"sec"
testm x,"sech"

p cot(1)

exit

a= -i * log( sqrt(1-x**2)*i + x )
b= -i * log( sqrt(x**2-1) + x )
p a
p b
p a-b

a= -i * log( sqrt(1-x**2) + x*i )
b= -i * log( (-sqrt(x**2-1) + x)*i )
p a
p b
p a-b