[Scilab-users] Strange behavior of explicit vs implicit iteration

serge.steer at laposte.net serge.steer at laposte.net
Mon Apr 25 10:35:09 CEST 2022


‌Do not forget you are doing numerical computations. This king of calculus implies rounding (the data are stored with a finite number of bits...) This explains the differences you got.
 

De : "Federico Miyara"
A : "Users mailing list for Scilab"
Envoyé: lundi 25 Avril 2022 10:01
Objet : [Scilab-users] Strange behavior of explicit vs implicit iteration
 

Dear All,

Here I have the following script, where I compute the same thing using two iteration methods:
 
alfa = rand(1,10);
Rpr = rand();
R = rand();
Z = rand(10,200); 

G = zeros(1,200);
for i=1:200
   A = 0;
   B = 0;
   for k = 1:10
      A = A + Rpr*alfa(k) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R);  
      B = B + Rpr*(1 - alfa(k)) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R);
   end
   G(i) = (1 + A) / (1 + B);
end

A = 1;
B = 1;
for k = 1:10
   A = A + Rpr*alfa(k) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R);  
   B = B + Rpr*(1 - alfa(k)) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R);
end
G1 = A ./ B;

[M, ind] = max(abs(G - G1))


However, the last line shows that there are differences between both methods. They are tiny (near %eps), but I can't find nor imagine which is the reason.

NOTE: I kept the original formulas as in the script where the problem arised but changed the data. When I tried to use a simpler formula there was no difference.

Any idea?




Regards,

Federico Miyara

 

	
		
			
			Libre de virus. www.avast.com
		
	





_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20220425/78066408/attachment.htm>


More information about the users mailing list