-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathanalysis.m
154 lines (66 loc) · 2.89 KB
/
analysis.m
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
(* Copyright E.M.Clarke and Xudong Zhao, Jan 22, 1991 *)
(* PROPERTIES OF CONTINUOUS FUNCTIONS. *)
integer[round[b_]] := True;
(* Continuous[f[x], {x, x0}] is True when f is continuous at point x0. *)
(* UniformlyContinuous[f] is True when f uniformly continuous on its range. *)
(* UniformlyConvergent[sum[f[x, k], {k, n, infinity}], {x, c1, c2}] means
the summation converges uniformly on interval [c1, c2]. *)
(* The identity function is continuous everywhere. *)
Continuous[x_, {x_, _}] := True;
(* A constant function is continuous everywhere. *)
Continuous[a_, {x_, _}] := True/; IsConstant[a, x];
(* Addition and Multiplication are continuous. *)
ContinuousFunction[Plus] = True;
ContinuousFunction[Times] = True;
(* Monomials are continuous. *)
Continuous[a_ ^ n_?integer, {x_, x0_}] :=
True /;
IsConstant[n, x] && Continuous[a, {x, x0}] && WeakSimplify[or[a!=0, n>=0]];
(* A sum of continuous functions is continuous. *)
Continuous[sum[f_, {k_, n1_, n2_}], {x_, x0_}] :=
True /;
FreeQ[n1, infinity] && FreeQ[n2, infinity] && Continuous[f, {x, x0}];
(* The composition of two continuous functions is continuous. *)
Continuous[f_[a__], {x_, x0_}] :=
Apply[and, Map[Continuous[#, {x, x0}] &, {a}]] /;
ContinuousFunction[f];
(* A continuous function whose domain is a closed set is uniformily
continuous. *)
UniformlyContinuous[f_] := True /;
ContinuousFunction[f] && Closed[Domain[f]];
(* Decide if a term is constant with respect to a certain variable. *)
IsConstant[Pi, x_] := True;
IsConstant[Const[___], x_] := True;
IsConstant[f_, x_] := False /; !FreeQ[f, x];
IsConstant[f_[a___], x_] :=
Apply[and, Map[IsConstant[#, x]&, {a}]] /; f=!=Var;
IsConstant[_?NumberQ, x_] := True;
(* Decide if a function is monotonic. *)
Increasing[delta[f_]] := True;
Increasing[inverse[f_]] := Increasing[f];
Decreasing[inverse[f_]] := Decreasing[f];
Increasing[_] := False;
Decreasing[_] := False;
(* Decide if a function is bounded. *)
Bounded[f_] := True /; ContinuousFunction[f] && Closed[Domain[f]];
(* Decide if a set is closed. *)
Closed[ClosedInterval[a_, b_]] := True;
(* Properties of inverse functions. *)
inverse /: f_[inverse[f_][x_]] := x;
inverse[f_][f_[x_]] := x;
(* Delta is from the epsilon - delta argument about the continuity of
function, written as delta[f][epsilon]. *)
delta /: (0 < delta[_][_]) := True;
delta /: (0 <= delta[_][_]) := True;
delta /: (delta[_][_] < 0) := False;
delta /: (delta[_][_] <= 0) := False;
inverse /: (0 < inverse[delta[_]][_]) := True;
inverse /: (0 <= inverse[delta[_]][_]) := True;
inverse /: (inverse[delta[_]][_] < 0) := False;
inverse /: (inverse[delta[_]][_] <= 0) := False;
(* Bound[f] gives an upper bound on the absolute value of a bounded
function f. *)
Bound /: (Bound[_] < 0) := False;
Bound /: (Bound[_] <= 0) := False;
Bound /: (0 < Bound[_]) := True;
Bound /: (0 <= Bound[_]) := True;