First when posting code in a wiki, use a 'code' block rather than simply color it. That will preserve indents and and other problems (like smilies).
Your inefficency is that you are progressing through the file multiple times, once for each line of the file. You are also dealing with each line in sequence.
So why not just go though the file once only, saving the intermediate value in a internal variable!
Code:
e=2.7182818284590452
awk '
BEGIN { e = '"$e"'; ans = 0 }
NR == 1 { ans = ($3/$4) * (e^($4*(0/2))-1);
print $0, ans
next
}
{ ans = ($3/$4 + ans) * (e^($4*(0.004/2))-1) + ans;
print $0, ans
}
' TWT.tmp > TWT.out2
Results are the same as your script, and only does one pass through the file.
Technically the first line will always be zero as the zero in the
expression makes the result always zero.
EG: The first line may as well simply be...
Code:
NR == 1 { print $0, 0; next; }
Similay you actually don't need to declare "ans = 0" as that is the default for any variable that has not been defined yet.