comparison scripts/general/quadl.m @ 12802:412882f498b4

codesprint: Wrote 5 tests for quadl.m
author David Wells <drwells@vt.edu>
date Sat, 16 Jul 2011 12:52:47 -0500
parents f96b9b9f141b
children 85dac13a911b
comparison
equal deleted inserted replaced
12801:2837514cf178 12802:412882f498b4
192 r = w; 192 r = w;
193 else 193 else
194 w = v; 194 w = v;
195 endif 195 endif
196 endfunction 196 endfunction
197
198
199 ## basic functionality
200 %!assert( quadl (@(x) sin (x), 0, pi, [], []), 2, -3e-16)
201
202 ## the values here are very high so it may be unavoidable that this fails
203 %!assert ( quadl (@(x) sin (3*x).*cosh (x).*sinh (x),10,15),
204 %! 2.588424538641647e+10, -9e-15)
205
206 ## extra parameters
207 %!assert (quadl (@(x,a,b) sin (a + b*x), 0, 1, [], [], 2, 3),
208 %! cos(2)/3 - cos(5)/3, - 3e-16)
209
210 ## test different tolerances. This test currently fails for a very high
211 ## tolerances.
212 %!assert ( quadl (@(x) sin (2 + 3*x).^2, 0, 10, 0.3, []),
213 %! (60 + sin(4) - sin(64))/12, -0.3)
214
215
216 ## for lower tolerances the test passes.
217 %!assert ( quadl (@(x) sin (2 + 3*x).^2, 0, 10, 0.1, []),
218 %! (60 + sin(4) - sin(64))/12, -0.1)