Skip to main content

All Questions

Tagged with
1 vote
1 answer
209 views

Mismatch between Matlab log and Numpy np.log

While rewriting an old Matlab code to NumPy, I noticed differences in logarithmic calculation. In NumPy, I use np.log, Matlab uses log function. b = [1 1 2 3 5 1 1]; p = b ./ sum(b); sprintf('log(%....
Martin Benes's user avatar
9 votes
1 answer
2k views

Avoiding overflow in log(cosh(x))

My simulation needs to implement np.log(np.cosh(x)) This overflows for large x, i. e. I'm getting the RuntimeWarning: overflow encountered in cosh warning. In principle, as logarithm decreases the ...
WojciechR's user avatar
  • 333