MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Problems with DO and TABLE...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2092] Problems with DO and TABLE...
  • From: lfreitas at ift.unesp.br (Luciene Pontes Freitas)
  • Date: Fri, 29 Sep 1995 01:14:31 -0400

Dear Wizards,

I've been tried to evaluate a function I've been called B[n,t,x] with fixed 
n,x and  the parameter 'a', and the variable t in the range [t1,t2] with a 
step st. I tried to do that using two different methods: 
1) The Do command, as you can see in the function P[x,t,t1,t2,st]; 
2) Using a Table, as showed in the function P1[n_,x_,t1_,t2_,st_].

The results I've been found were:

***********   RESULTS   ***************
In[2]:= a:=3.1

In[3]:= P[4,.7,1,2,.2]
B1[4,1,0.7] = {0.79 Second, 0.758841}
B1[4,1.2,0.7] = {0.79 Second, 1.33161}
B1[4,1.4,0.7] = {0.79 Second, 2.49627}
B1[4,1.6,0.7] = {0.79 Second, 4.97146}
B1[4,1.8,0.7] = {0.78 Second, 10.4205}
B1[4,2.,0.7] = {0.78 Second, 22.7483}


In[9]:= P1[4,.7,1,2,.2]

Out[9]= {{0.79 Second, 0.758841}, 
	{0.79 Second, 1.33161},
	{0.79 Second, 2.49627}, 
	{0.8 Second, 4.97146}, 
	{0.79 Second,10.4205},
	{0.78 Second, 22.7483}}
******************************************

But if I calculate the function B[n,t,x] for each t in the same points 
I've done to the functions P[...] and P1[...] the results are different 
of those ones.
Example: In[3]:= B1[4,1,0.7]
	 Out[3]= {0.85 Second, 0.651}

	 In[4]:= B1[4,1.6,0.7]
	 Out[4]= {0.84 Second, 0.841106}

Which problem could be happening in this calculation?
I'm sure the results above (given by B1[...]) are right.

				Thanks in advance
				  Luciene.

*********  The definitions used    ******************************

x[j_]:=-a^(-j);

Pro[n_,x_,t_]:=Product[(1+t*x[i]),{i,n}];

Sigma[n_,j_]:=Coefficient[Pro[n,x,t],t,j];

(Zigmund[n_,k_,i_]:=Sum[(a^(i*j))*Sigma[n,j],{j,0,k-1}]);

(Funct[n_,i_]:=Sum[Zigmund[n,k,i],{k,1,n}]);

(Ro[n_,i_,k_]:=Sum[(a^(i*(j-k)))*Sigma[n,j],{j,0,k-1}]/Funct[n,i]);

(Coef[n_,k_,t_]:=Sum[Ro[n,i,k]*a^(i*t),{i,1,n}]);

g[x_]:=a*x*(1-x);

" defining a value to variable 'a', example a:=3.1 "

a:=3.1

B1[n_,t_,x_]:=Timing[Sum[Coef[n,k,t]*Nest[g,x,k],{k,1,n}]];

P[n_,x_,t1_,t2_,st_]:=Do[Print["B1[",n,",",t,",",x,"]"," = ",
			B1[n,t,x]],{t,t1,t2,st}];

P1[n_,x_,t1_,t2_,st_]:=Table[B1[n,t,x],{t,t1,t2,st}]

***************************************************************


  • Prev by Date: strange Integrate[] behavior
  • Next by Date: Re: histogram
  • Previous by thread: strange Integrate[] behavior
  • Next by thread: Is this rule-based solution efficient?