Re: Table[ ...If[...i...] ,{i,...}]
- To: mathgroup-adm at yoda.physics.unc.edu
- Subject: Re: Table[ ...If[...i...] ,{i,...}]
- From: David Sibley <sibley at math.psu.edu>
- Date: Fri, 17 Jul 92 15:18:51 -0400
The original problem was with Table[ v[i]'[t] == If[ x[i]>0,ex1,ex2] , {i,2,6} ] I fooled with this a bit and think I see what's going on. Apparently mma does indeed substitute correctly for all the i's, but when it discovers that the If evaluates to neither True nor False, sticks back in the form of the If with i's in it rather than numbers. Thus, this seems to be a bug. It occurs in an anomolous situation, to be sure, but it is certainly not the expected behavior. To see how I reached the above conclusion, try: Table[ If[ x[i], i, -i ], {i,2,6} ] Table[ If[ x[i], i, -i , i^2 ], {i,2,6} ] and x[3] = True Table[ If[ x[i], i, -i ], {i,2,6} ] Finally, as a workaround the following seems OK, though Lord knows why. Table[ If[ x[t], t, -t ]/.t->i, {i,2,6} ] David Sibley sibley at math.psu.edu