-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmymath.F
More file actions
60 lines (55 loc) · 1.26 KB
/
mymath.F
File metadata and controls
60 lines (55 loc) · 1.26 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
c Simple mathematic functions
c
ccccccccccccccccccccccccccccccccccccc
c Factrization
c
integer function myfact(n)
implicit none
integer,intent(in) :: n
integer :: i
myfact=1
do i=1,n
myfact=myfact*i
enddo
end function myfact
ccccccccccccccccccccccccccccccccccccc
c Permutation
c
integer function myperm(n,m)
implicit none
integer,intent(in) :: n,m
integer :: i
myperm=1
do i=0,m-1
myperm=myperm*(n-i)
enddo
end function myperm
ccccccccccccccccccccccccccccccccccccc
c Combination
c
integer function mycomb(n,m)
implicit none
integer,intent(in) :: n,m
integer :: i,nmm
c function
integer :: myperm,myfact
nmm=m
if (n-m.lt.m) nmm=n-m
mycomb=myperm(n,nmm)/myfact(nmm)
end function mycomb
cccccccccccccccccccccccccccccccccccc
c Calculate m-th derivative of x^n
c (d/dx^m) x^n = n*(n-1)*...*(n-m+1)*x^(n-m)
c
double precision function mydif(x,n,m)
implicit none
double precision,intent(in) :: x
integer,intent(in) :: n,m
c function
integer :: myperm
if (m.gt.n) then
mydif=0
return
endif
mydif=dble(myperm(n,m))*x**(n-m)
end function mydif