This is part of my file
4.997 0.0110329
4.998 0.0110245
4.999 0.0110324
5 0.0110272
When I run my script"
#!/bin/bash
awk '{$2=((0.231771*exp(-$1/0.00142118) 0.299638*exp(-$1/0.0500264) 0.318124*exp(-$1/0.332495) 0.150467*exp(-$1/1.8087))-$2); print}' lut_ver_eps_900_1100_v5.xvg | tee lut_ver_eps_900_1100_v5_roznice.xvg
I get an error like
1: (FILENAME=lut_ver_eps_900_1100_v5.xvg FNR=5001) ostrzeżenie: exp: argument -3518.2 jest poza zasięgiem
Translate to English
1: (FILENAME=lut_ver_eps_900_1100_v5.xvg FNR=5001) warning: exp: argument -3518.2 is out of range
What I should change?
I get the result
4.997 -0.00153571
4.998 -0.00153256
4.999 -0.00154571
5 -0.00154575
but I don't know that everything is fine
CodePudding user response:
exp(-1300)
would evaluate to a very small value very close to 0. It is so small that the result of the calculation cannot be represented in the machine's floating point format. Probably awk is outputting '0', which, depending on your goal, may be fine.
CodePudding user response:
exp
does
Return the exponential of x (
e ^ x
) or report an error if x is out of range. The range of values x can have depends on your machine’s floating-point representation.
if you do not want to have errors, but rather zero you might replace e.g.
exp(-10000)
using
2.7183^(-10000)
after replacing 2.7183
with e approximation close enough for your needs