Mercurial > octave-antonio
diff scripts/specfun/expint.m @ 16585:1a3bfb14b5da
Add and fix tests for ellipj, ellipke, and expint
* ellipj.cc: Fix demo, add validation tests.
* ellipke.m: Fix assert arguments, add tests.
* expint.m: Add tests.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Sun, 28 Apr 2013 17:08:11 -0400 |
parents | 2f766ceeb03e |
children | f423873d3275 |
line wrap: on
line diff
--- a/scripts/specfun/expint.m Wed Apr 24 23:22:50 2013 -0400 +++ b/scripts/specfun/expint.m Sun Apr 28 17:08:11 2013 -0400 @@ -105,3 +105,67 @@ endif endfor endfunction + +%% Test against A&S Table 5.1 +%!test +%! x = [5:5:50]'/100; +%! gamma = 0.5772156649; +%! y_exp = [0.9876375971; +%! 0.9755453033; +%! 0.9637156702; +%! 0.9521414833; +%! 0.9408157528; +%! 0.9297317075; +%! 0.9188827858; +%! 0.9082626297; +%! 0.8978650778; +%! 0.8876841584 ]; +%! y = (expint (x) + log(x) + gamma) ./ x; +%! assert (y, y_exp, 1e-9); +%!test +%! x = [50:5:95]'/100; +%! y_exp = [0.559773595; +%! 0.503364081; +%! 0.454379503; +%! 0.411516976; +%! 0.373768843; +%! 0.340340813; +%! 0.310596579; +%! 0.284019269; +%! 0.260183939; +%! 0.238737524 ]; +%! y = expint (x); +%! assert (y, y_exp, 1e-9); +%!test +%! x = [100:5:145]'/100; +%! y_exp = [0.219383934; +%! 0.201872813; +%! 0.185990905; +%! 0.171555354; +%! 0.158408437; +%! 0.146413373; +%! 0.135450958; +%! 0.125416844; +%! 0.116219313; +%! 0.107777440 ]; +%! y = expint (x); +%! assert (y, y_exp, 1e-9); +%!test +%! x = [150:5:200]'/100; +%! y_exp = [0.100019582; +%! 0.092882108; +%! 0.086308334; +%! 0.080247627; +%! 0.074654644; +%! 0.069488685; +%! 0.064713129; +%! 0.060294967; +%! 0.056204378; +%! 0.052414380; +%! 0.048900511 ]; +%! y = expint (x); +%! assert (y, y_exp, 1e-9); + +%% Test input validation +%!error expint () +%!error expint (1,2)