changeset 2542:966fda525f93 octave-forge

Errors fixed.
author sis-sou
date Mon, 02 Oct 2006 05:45:38 +0000
parents 4ff100278d10
children 85d419c88555
files main/specfun/inst/Si.m
diffstat 1 files changed, 8 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/main/specfun/inst/Si.m	Sun Oct 01 21:53:50 2006 +0000
+++ b/main/specfun/inst/Si.m	Mon Oct 02 05:45:38 2006 +0000
@@ -14,37 +14,17 @@
 ## along with this program; if not, write to the Free Software
 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-## SI compute the sine integral,
-##
-##                x
-##               /
-##    Si(x) =    | sin(t)/t dt
-##               /
-##               0
-##
 
 function y = Si(x)
 		if (nargin != 1)
 			usage ("Si(x)");
 	   endif
-		s = size(x)(2);
-		for t = 1:s
-			if( x == 0)
-				y = 0;
-			else
-				if(imag(x(t)) == 0)
-					F = @(x) sin(x)./x;
-					y(t) = quad(F,0,x(t));
-				else
-					y(t) = 0;
-					for k = 0:100
-						y(t) = y(t) + (besselj(k + 0.5,x(t)./2)).^2;
-					endfor
-					y(t) = y(t).*pi;
-					if(real(x(t))==0)
-						y(t)=i.*imag(y(t));
-					endif
-				endif
-			endif
+		y = 0;
+
+		for k = 0:100
+			y = y + (besselj(k + 0.5,x./2)).^2;
 		endfor
-endfunction
\ No newline at end of file
+		y = y.*pi;
+		y(x == 0) = 0;
+		y(real(x)==0) = i.*imag(y(real(x)==0));
+endfunction;
\ No newline at end of file