how does cycles calculate RGB to BW
Black and white, or more appropriately greyscale, is based on the luminance weights of the primary lights for a given reference. That is, not physical energy, but visual energy. If one were to project equal energy sRGB values from a screen, despite being equal physical energy, the visual energy would appear as though the sRGB green channel was most luminous, with red following, and blue seeming the least luminous.

As one can clearly see from the above example, luminance is not an equal average of each channel.  There are countless clueless formulas for calculating greyscale imagery based off of equally clueless offerings, including such averaging and other misinformed foolishness.

The default reference space for Blender is based upon REC.709 primaries, as those are the primaries that define the sRGB specification. As such, to properly calculate greyscale, we use the normalized luminance, or the normalized Y value for each primary as given under the CIE XYZ model, to weight the sRGB values.

Those weights are typically represented as 0.2126*R + 0.7152*G + 0.0722*B. Blender utilizes the values from the OpenColorIO configuration as given on the "luma" line in https://git.blender.org/gitweb/gitweb.cgi/blender.git/blob_plain/HEAD:/release/datafiles/colormanagement/config.ocio.

For any given RGB colourspace such as sRGB, there is exactly one correct method to derive average luminance.