UNPKG

2.04 kBtext/coffeescriptView Raw
1test_derivative = ->
2 run_test [
3
4 "x=quote(x)",
5 "",
6
7 "f=quote(f)",
8 "",
9
10 "g=quote(g)",
11 "",
12
13 "d(a,x)",
14 "0",
15
16 "d(x,x)",
17 "1",
18
19 "d(x^2,x)",
20 "2*x",
21
22 "d(log(x),x)",
23 "1/x",
24
25 "d(exp(x),x)",
26 "exp(x)",
27
28 "d(a^x,x)",
29 "a^x*log(a)",
30
31 "d(x^x,x)-(x^x+x^x*log(x))",
32 "0",
33
34 "d(log(x^2+5),x)-(2*x/(5+x^2))",
35 "0",
36
37 "d(d(f(x),x),y)",
38 "0",
39
40 "d(d(f(x),y),x)",
41 "0",
42
43 "d(d(f(y),x),y)",
44 "0",
45
46 "d(d(f(y),y),x)",
47 "0",
48
49 "d([x*y*z,y,x+z],[x,y,z])",
50 "[[y*z,x*z,x*y],[0,1,0],[1,0,1]]",
51
52 "d(x+z,[x,y,z])",
53 "[1,0,1]",
54
55 "d(cos(theta)^2,cos(theta))",
56 "2*cos(theta)",
57
58 "d(f())",
59 "d(f(),x)",
60
61 "d(x^2)",
62 "2*x",
63
64 "d(t^2)",
65 "2*t",
66
67 "d(t^2 x^2)",
68 "2*t^2*x",
69
70 # trig functions
71
72 "d(sin(x),x)-cos(x)",
73 "0",
74
75 "d(cos(x),x)+sin(x)",
76 "0",
77
78 "d(tan(x),x)-cos(x)^(-2)",
79 "0",
80
81 "d(arcsin(x),x)-1/sqrt(1-x^2)",
82 "0",
83
84 "d(arccos(x),x)+1/sqrt(1-x^2)",
85 "0",
86
87 "d(arctan(x),x)-1/(1+x^2)",
88 "0",
89
90 "d(arctan(y/x),x)",
91 "-y/(x^2+y^2)",
92
93 "d(arctan(y/x),y)",
94 "x/(x^2+y^2)",
95
96 # hyp functions
97
98 "d(sinh(x),x)-cosh(x)",
99 "0",
100
101 "d(cosh(x),x)-sinh(x)",
102 "0",
103
104 "d(tanh(x),x)-cosh(x)^(-2)",
105 "0",
106
107 "d(arcsinh(x),x)-1/sqrt(x^2+1)",
108 "0",
109
110 "d(arccosh(x),x)-1/sqrt(x^2-1)",
111 "0",
112
113 "d(arctanh(x),x)-1/(1-x^2)",
114 "0",
115
116 "d(sin(cos(x)),x)+cos(cos(x))*sin(x)",
117 "0",
118
119 "d(sin(x)^2,x)-2*sin(x)*cos(x)",
120 "0",
121
122 "d(sin(cos(x)),cos(x))-cos(cos(x))",
123 "0",
124
125 "d(abs(x),x)",
126 "sgn(x)",
127
128 "d(sgn(x),x)",
129 "2*dirac(x)",
130
131 # generic functions
132
133 "d(f(),x)",
134 "d(f(),x)",
135
136 "d(f(x),x)",
137 "d(f(x),x)",
138
139 "d(f(y),x)",
140 "0",
141
142 "d(g(f(x)),f(x))",
143 "d(g(f(x)),f(x))",
144
145 "d(g(f(x)),x)",
146 "d(g(f(x)),x)",
147
148 # other functions
149
150 "d(erf(x))-2*exp(-x^2)/sqrt(pi)",
151 "0",
152
153 # arg lists
154
155 "f=x^5*y^7",
156 "",
157
158 "d(f)",
159 "5*x^4*y^7",
160
161 "d(f,x)",
162 "5*x^4*y^7",
163
164 "d(f,x,0)",
165 "x^5*y^7",
166
167 "d(f,x,1)",
168 "5*x^4*y^7",
169
170 "d(f,x,2)",
171 "20*x^3*y^7",
172
173 "d(f,2)",
174 "20*x^3*y^7",
175
176 "d(f,2,y)",
177 "140*x^3*y^6",
178
179 "d(f,x,x,y,y)",
180 "840*x^3*y^5",
181
182 "f=quote(f)",
183 "",
184 ]