Band Math results not has expected and divided by zero error

Are you aware that SNAP applies a scaling factors to many products while r works on the raw image data?
Some considerations here: About scaling factor and exporting product etc

Calculations performed in SNAP might give different results than based on the rasters alone.