x<-seq(-1,1,length=10)
y<-seq(-1,1,length=10)
a<-matrix(c(1,2,2,1),2,2)
b<-matrix(c(2,1,1,2),2,2)

fv<-function(x,y) {
	m<-x*a+y*b
	t<-m[1,1]+m[2,2]; d<-m[1,1]*m[2,2]-m[1,2]^2
	return((t-sqrt(t^2-4*d))/2)
}

gv<-function(x,y) {
	t<-x*(a[1,1]+a[2,2])+y*(b[1,1]+b[2,2])
	d<-(x*a[1,1]+y*b[1,1])*(x*a[2,2]+y*b[2,2])-(x*a[1,2]+y*b[1,2])^2
	return((t-sqrt(t^2-4*d))/2)
}


now outer(x,y,gv) works as expected, outer(x,y,fv) bombs. But

z<-matrix(0,10,10); for (i in 1:10) for (j in 1:10) z[i,j]<-fv(x[i],y 
[j])

works fine. Must be something in outer().

==========================================================
Jan de Leeuw, 11667 Steinhoff Rd, Frazier Park, CA 93225, 661-245-1725
.mac: jdeleeuw ++++++  aim: deleeuwjan ++++++ skype: j_deleeuw
homepages: http://www.cuddyvalley.org and http://gifi.stat.ucla.edu
==========================================================
                A bath when you're born,
           a bath when you die,
                how stupid.          (Issa 1763-1827)




	[[alternative HTML version deleted]]

