G'day, folks 😃
Are there any general principles that might govern how a calculation should be structured? Any things that can be considered to apply independent of the data which the calculation is handling?
For example,
(a + b + c) / d is algebraically equivalent to a/d + b/d + c/d but does that equivalence apply to processing on a limited-precision machine? In other words, does structure matter when writing the code? I'm thinking of things which are independent of the data. If the 'ideal' structure is not independent of the data then I guess we have a whole new kettle of porcupines!
Here's the actual segment of code that has got me thinking about this possibility -
C
C here for isothermal calculation
C
f0(i) = (10.0**(c2)) * tinc + f0(i)
goto 400
C
C here for non-isothermal calculation
C
300 dm = c1 * aln10
f0(i) = (10.0**(c1*tinc+c2))/dm + f0(i) - (10.0**c2)/dm
C
In particular, I wondered if the 'accumulator' f0(i) should be real*8, thinking that the results of the exponentiation (p1 & p2) should be tested before they possibly distorted the rest of the calculation.
C
C here for isothermal calculation
C
route='I'
p1=10.0**c2
f0 = dble(p1 * tinc) + f0
goto 400
C
C here for non-isothermal calculation
C
300 route='N'
dm = c1 * aln10
p1=10.0**c2
p2=10.0**(c1*tinc+c2)
f0 = dble(p2/dm) + f0 - dble(p1/dm)
C
Eric