I am programming a numerical analysis program and sometimes the calculus give in some of the coefficients really small numbers i.e a0=1.234542e-12
If I calculate an array of 10 values (from which i.e. 6 of them are small numbers) and later on I multiply each of them by t^x (just as an example)
being x=1:10, what is faster computationally?
- just leave the small number as they are
- Detect numbers that are lower than
thresholdand substitute them by 0.0
The question is mainly because maybe the compiler just doesn’t make the calculus of a number multiplied by 0 because it always is 0, or it may just multiply it and I am making the program slower for adding if conditionals just to check if a number is 0 or not.
If you are asking, as you seem to be, which is the faster of these 2 operations:
well, I think that in the limit 1 will be faster than 2.